@@ -31,7 +31,10 @@ class Placeorder
31
31
* 用户的支付方式.
32
32
*/
33
33
public $ _payment_method ;
34
-
34
+ /**
35
+ * 订单备注信息.
36
+ */
37
+ public $ _order_remark ;
35
38
public function getLastData ()
36
39
{
37
40
$ post = Yii::$ app ->request ->post ();
@@ -59,7 +62,7 @@ public function getLastData()
59
62
// 将购物车数据,生成订单,生成订单后,不清空购物车,不扣除库存,在支付成功后在清空购物车。
60
63
$ innerTransaction = Yii::$ app ->db ->beginTransaction ();
61
64
try {
62
- $ genarateStatus = Yii::$ service ->order ->generateOrderByCart ($ this ->_billing , $ this ->_shipping_method , $ this ->_payment_method , false ,$ token );
65
+ $ genarateStatus = Yii::$ service ->order ->generateOrderByCart ($ this ->_billing , $ this ->_shipping_method , $ this ->_payment_method , false , $ token, $ this -> _order_remark );
63
66
if ($ genarateStatus ) {
64
67
$ innerTransaction ->commit ();
65
68
} else {
@@ -223,7 +226,20 @@ public function checkOrderInfoAndInit($post)
223
226
return false ;
224
227
}
225
228
}
226
-
229
+ // 订单备注信息不能超过1500字符
230
+ $ orderRemarkStrMaxLen = Yii::$ service ->order ->orderRemarkStrMaxLen ;
231
+ $ order_remark = isset ($ post ['order_remark ' ]) ? $ post ['order_remark ' ] : '' ;
232
+ if ($ order_remark && $ orderRemarkStrMaxLen ) {
233
+ $ order_remark_strlen = strlen ($ order_remark );
234
+ if ($ order_remark_strlen > $ orderRemarkStrMaxLen ) {
235
+ Yii::$ service ->helper ->errors ->add ('order remark string length can not gt ' .$ orderRemarkStrMaxLen );
236
+
237
+ return false ;
238
+ } else {
239
+ // 去掉xss攻击字符,关于防止xss攻击的yii文档参看:http://www.yiichina.com/doc/guide/2.0/security-best-practices#fang-zhi-xss-gong-ji
240
+ $ this ->_order_remark = $ order_remark ;
241
+ }
242
+ }
227
243
$ this ->_shipping_method = $ shipping_method ;
228
244
$ this ->_payment_method = $ payment_method ;
229
245
Yii::$ service ->payment ->setPaymentMethod ($ this ->_payment_method );
0 commit comments