Skip to content

Commit

Permalink
订单备注完善
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyecommerce committed Dec 11, 2017
1 parent eea16dd commit 417c51f
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 18 deletions.
22 changes: 19 additions & 3 deletions app/appfront/modules/Payment/block/paypal/express/Placeorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ class Placeorder
* 用户的支付方式.
*/
public $_payment_method;

/**
* 订单备注信息.
*/
public $_order_remark;
public function getLastData()
{
$post = Yii::$app->request->post();
Expand Down Expand Up @@ -59,7 +62,7 @@ public function getLastData()
// 将购物车数据,生成订单,生成订单后,不清空购物车,不扣除库存,在支付成功后在清空购物车。
$innerTransaction = Yii::$app->db->beginTransaction();
try {
$genarateStatus = Yii::$service->order->generateOrderByCart($this->_billing, $this->_shipping_method, $this->_payment_method, false,$token);
$genarateStatus = Yii::$service->order->generateOrderByCart($this->_billing, $this->_shipping_method, $this->_payment_method, false, $token, $this->_order_remark);
if ($genarateStatus) {
$innerTransaction->commit();
} else {
Expand Down Expand Up @@ -223,7 +226,20 @@ public function checkOrderInfoAndInit($post)
return false;
}
}

// 订单备注信息不能超过1500字符
$orderRemarkStrMaxLen = Yii::$service->order->orderRemarkStrMaxLen;
$order_remark = isset($post['order_remark']) ? $post['order_remark'] : '';
if ($order_remark && $orderRemarkStrMaxLen) {
$order_remark_strlen = strlen($order_remark);
if ($order_remark_strlen > $orderRemarkStrMaxLen) {
Yii::$service->helper->errors->add('order remark string length can not gt '.$orderRemarkStrMaxLen);

return false;
} else {
// 去掉xss攻击字符,关于防止xss攻击的yii文档参看:http://www.yiichina.com/doc/guide/2.0/security-best-practices#fang-zhi-xss-gong-ji
$this->_order_remark = $order_remark;
}
}
$this->_shipping_method = $shipping_method;
$this->_payment_method = $payment_method;
Yii::$service->payment->setPaymentMethod($this->_payment_method);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
<div class="coupon_add_log"></div>
</div>

<div class="onestepcheckout-coupons">
<div class="op_block_title"><?= Yii::$service->page->translate->__('Order Remark (optional)');?></div>
<label for="id_couponcode"><?= Yii::$service->page->translate->__('You can fill in the order remark information below');?></label>
<textarea class="order_remark" name="order_remark" style="width:94%;height:100px;padding:10px;"></textarea>
</div>

</div>

Expand Down
22 changes: 19 additions & 3 deletions app/apphtml5/modules/Payment/block/paypal/express/Placeorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ class Placeorder
* 用户的支付方式.
*/
public $_payment_method;

/**
* 订单备注信息.
*/
public $_order_remark;
public function getLastData()
{
$post = Yii::$app->request->post();
Expand Down Expand Up @@ -59,7 +62,7 @@ public function getLastData()
// 将购物车数据,生成订单,生成订单后,不清空购物车,不扣除库存,在支付成功后在清空购物车。
$innerTransaction = Yii::$app->db->beginTransaction();
try {
$genarateStatus = Yii::$service->order->generateOrderByCart($this->_billing, $this->_shipping_method, $this->_payment_method, false,$token);
$genarateStatus = Yii::$service->order->generateOrderByCart($this->_billing, $this->_shipping_method, $this->_payment_method, false, $token, $this->_order_remark);
if ($genarateStatus) {
$innerTransaction->commit();
} else {
Expand Down Expand Up @@ -223,7 +226,20 @@ public function checkOrderInfoAndInit($post)
return false;
}
}

// 订单备注信息不能超过1500字符
$orderRemarkStrMaxLen = Yii::$service->order->orderRemarkStrMaxLen;
$order_remark = isset($post['order_remark']) ? $post['order_remark'] : '';
if ($order_remark && $orderRemarkStrMaxLen) {
$order_remark_strlen = strlen($order_remark);
if ($order_remark_strlen > $orderRemarkStrMaxLen) {
Yii::$service->helper->errors->add('order remark string length can not gt '.$orderRemarkStrMaxLen);

return false;
} else {
// 去掉xss攻击字符,关于防止xss攻击的yii文档参看:http://www.yiichina.com/doc/guide/2.0/security-best-practices#fang-zhi-xss-gong-ji
$this->_order_remark = $order_remark;
}
}
$this->_shipping_method = $shipping_method;
$this->_payment_method = $payment_method;
Yii::$service->payment->setPaymentMethod($this->_payment_method);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,25 @@
<table class="onestepcheckout-totals">
<tbody>
<tr>
<td ><?= Yii::$service->page->translate->__('Subtotal') ?></td>
<td class="totals"><?= Yii::$service->page->translate->__('Subtotal') ?></td>
<td class="value">
<span class="price"><?= $currency_info['symbol']; ?><?= Format::price($cart_info['product_total']); ?></span>
</td>
</tr>
<tr>
<td ><?= Yii::$service->page->translate->__('Shipping Cost') ?></td>
<td class="totals"><?= Yii::$service->page->translate->__('Shipping Cost') ?></td>
<td class="value">
<span class="price"><?= $currency_info['symbol']; ?><?= Format::price($cart_info['shipping_cost']); ?></span>
</td>
</tr>
<tr>
<td ><?= Yii::$service->page->translate->__('Discount') ?></td>
<td class="totals"><?= Yii::$service->page->translate->__('Discount') ?></td>
<td class="value">
<span class="price">-<?= $currency_info['symbol']; ?><?= Format::price($cart_info['coupon_cost']); ?></span>
</td>
</tr>
<tr class="grand-total">
<td ><?= Yii::$service->page->translate->__('Grand Total') ?></td>
<td class="totals"><?= Yii::$service->page->translate->__('Grand Total') ?></td>
<td class="value">
<span class="price"><?= $currency_info['symbol']; ?><?= Format::price($cart_info['grand_total']) ?></span>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@
<div class="coupon_add_log"></div>
</div>


<div class="onestepcheckout-coupons">
<div class="op_block_title"><?= Yii::$service->page->translate->__('Order Remark (optional)');?></div>
<label for="id_couponcode"><?= Yii::$service->page->translate->__('You can fill in the order remark information below');?></label>
<textarea class="order_remark" name="order_remark" style="width:100%;height:100px;padding:10px;"></textarea>
</div>
</div>

<div class="onestepcheckout-column-right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,25 @@
<table class="onestepcheckout-totals">
<tbody>
<tr>
<td class="title"><?= Yii::$service->page->translate->__('Subtotal') ?></td>
<td class="totals"><?= Yii::$service->page->translate->__('Subtotal') ?></td>
<td class="value">
<span class="price"><?= $currency_info['symbol']; ?><?= Format::price($cart_info['product_total']); ?></span>
</td>
</tr>
<tr>
<td class="title"><?= Yii::$service->page->translate->__('Shipping Cost') ?></td>
<td class="totals"><?= Yii::$service->page->translate->__('Shipping Cost') ?></td>
<td class="value">
<span class="price"><?= $currency_info['symbol']; ?><?= Format::price($cart_info['shipping_cost']); ?></span>
</td>
</tr>
<tr>
<td class="title"><?= Yii::$service->page->translate->__('Discount') ?></td>
<td class="totals"><?= Yii::$service->page->translate->__('Discount') ?></td>
<td class="value">
<span class="price">-<?= $currency_info['symbol']; ?><?= Format::price($cart_info['coupon_cost']); ?></span>
</td>
</tr>
<tr class="grand-total">
<td class="title"><?= Yii::$service->page->translate->__('Grand Total') ?></td>
<td class="totals"><?= Yii::$service->page->translate->__('Grand Total') ?></td>
<td class="value">
<span class="price"><?= $currency_info['symbol']; ?><?= Format::price($cart_info['grand_total']) ?></span>
</td>
Expand Down
21 changes: 18 additions & 3 deletions app/appserver/modules/Payment/block/paypal/express/Placeorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ class Placeorder
* 用户的支付方式.
*/
public $_payment_method;


public $_order_remark;

public function getLastData()
{
$post = Yii::$app->request->post();
Expand Down Expand Up @@ -66,7 +68,7 @@ public function getLastData()
// 将购物车数据,生成订单,生成订单后,不清空购物车,不扣除库存,在支付成功后在清空购物车。
$innerTransaction = Yii::$app->db->beginTransaction();
try {
$genarateStatus = Yii::$service->order->generateOrderByCart($this->_billing, $this->_shipping_method, $this->_payment_method, false,$token);
$genarateStatus = Yii::$service->order->generateOrderByCart($this->_billing, $this->_shipping_method, $this->_payment_method, false, $token, $this->_order_remark);
if ($genarateStatus) {
$innerTransaction->commit();
} else {
Expand Down Expand Up @@ -266,7 +268,20 @@ public function checkOrderInfoAndInit($post)
}

}

// 订单备注信息不能超过1500字符
$orderRemarkStrMaxLen = Yii::$service->order->orderRemarkStrMaxLen;
$order_remark = isset($post['order_remark']) ? $post['order_remark'] : '';
if ($order_remark && $orderRemarkStrMaxLen) {
$order_remark_strlen = strlen($order_remark);
if ($order_remark_strlen > $orderRemarkStrMaxLen) {
Yii::$service->helper->errors->add('order remark string length can not gt '.$orderRemarkStrMaxLen);

return false;
} else {
// 去掉xss攻击字符,关于防止xss攻击的yii文档参看:http://www.yiichina.com/doc/guide/2.0/security-best-practices#fang-zhi-xss-gong-ji
$this->_order_remark = $order_remark;
}
}
$this->_shipping_method = $shipping_method;
$this->_payment_method = $payment_method;
Yii::$service->payment->setPaymentMethod($this->_payment_method);
Expand Down

0 comments on commit 417c51f

Please sign in to comment.