购物流程:
生成订单 --> 支付订单 --> 商家发货 --> 确认收货 --> 评价订单
1.买家在生成订单之后,支付订单之前可以取消订单
2.买家在支付订单之后,商家发货之前可以申请退款
3.买家在确认收货之后可以申请退货
#### 1.生成订单
文件路径:\shop\controllers\Buyer\OrderCtl.php
控制器:Buyer_OrderCtl
方法:addOrder()
判断选项的支付方式是否合法
~~~
/**
* 如果不是选 在线支付 或 货到付款 ,则提示错误
*/
if(!in_array($pay_way_id, [1,2])){
$data = [];
$status = 250;
$msg = "操作错误,请刷新当前页面!";
return $this->data->addBody(-140, $data, $msg, $status);
}
~~~
检测是否存在加价购商品,若存在则检测加价购商品信息是否正确。检测加价购商品正确性后重组加价购商品的活动规则,查找出活动中所有规则下的加价购商品信息
~~~
if($increase_arr)
{
//检验加价购商品信息是否正确
$increase_price_info = $this->checkIncreaseGoods($increase_arr, $cart_id);
if(!$increase_price_info)
{
return $this->data->addBody(-140, array('code'=>1), 'failure1', 250);
}
$increase_goods_id = array_column($increase_arr, 'increase_goods_id');
}
~~~
判断订单来源
~~~
//wap端下单
$order_from = Order_StateModel::FROM_WAP;
//pc端下单
$order_from = Order_StateModel::FROM_PC;
~~~
判断支付方式为在线支付还是货到付款,如果是货到付款则订单状态直接为待发货状态,如果是在线支付则订单状态为待付款
~~~
if($pay_way_id == PaymentChannlModel::PAY_ONLINE)
{
$order_status = Order_StateModel::ORDER_WAIT_PAY;
}
if($pay_way_id == PaymentChannlModel::PAY_CONFIRM)
{
$order_status = Order_StateModel::ORDER_WAIT_PREPARE_GOODS;
}
~~~
获取用户的平台折扣信息
~~~
$user_info = $User_InfoModel->getOne($user_id);
~~~
判断是否使用了代金券,如果使用了代金券,则处理代金券的信息
~~~
if ($voucher_id)
{
//查找代金券的信息
$Voucher_BaseModel = new Voucher_BaseModel();
$voucher_cond_row['voucher_id:IN'] = $voucher_id;
$voucher_row = $Voucher_BaseModel->getByWhere($voucher_cond_row);
$shop_voucher_row = array();
foreach ($voucher_row as $voukey => $vouval)
{
$shop_voucher_row[$vouval['voucher_shop_id']] = $vouval;
}
}
~~~
根据cart_id查找出购物车中的商品信息
~~~
$data = $CartModel->getCardList($cond_row, $order_row);
~~~
计算购物车中每件商品的最后优惠的实际价格
1.店铺商品总价 = 加价购商品总价 + 购物车商品总价(按照限时折扣和团购价计算)
2.判断平台是否开启会员折扣只限自营店铺使用。如果是平台自营店铺需要计算会员折扣,非平台自营不需要计算折扣
3.计算每个商品订单实际支付的金额,以及每件商品的实际支付单价为多少
4.平台红包的使用情况
查找收货地址,计算运费
~~~
$User_AddressModel = new User_AddressModel();
$city_id = 0;
if($address_id)
{
$user_address = $User_AddressModel->getOne($address_id);
$city_id = $user_address['user_address_city_id'];
}
$Transport_TemplateModel = new Transport_TemplateModel();
$transport_cost = $Transport_TemplateModel->cartTransportCost($city_id, $cart_id);
~~~
生成订单(order_base)
~~~
//生成订单号
$prefix = sprintf('%s-%s-', Yf_Registry::get('shop_app_id'), date('YmdHis'));
$order_number = $Number_SeqModel->createSeq($prefix);
$order_id = sprintf('%s-%s-%s-%s', 'DD', $val['shop_user_id'], $key, $order_number);
//生成订单发票信息
$Order_InvoiceModel = new Order_InvoiceModel();
$order_invoice_id = $Order_InvoiceModel->getOrderInvoiceId($invoice_id,$invoice_title,$invoice_content,$order_id);
//生成订单
$flag1 = $this->tradeOrderModel->addBase($order_row);
//修改用户使用的红包信息
if($rpacket_id)
{
if(isset($rpacket_id[$key]))
{
$redPacket_BaseModel = new RedPacket_BaseModel();
$field_row = array();
$field_row['redpacket_state'] = RedPacket_BaseModel::USED;
$field_row['redpacket_order_id'] = $order_id;
$flag5 = $redPacket_BaseModel->editRedPacket($rpacket_id[$key], $field_row);
$flag = $flag && $flag5;
}
}
//修改用户使用的代金券信息
if($val['voucher_id'])
{
if(isset($shop_voucher_row[$key]))
{
$Voucher_BaseModel = new Voucher_BaseModel();
$flag6 = $Voucher_BaseModel->changeVoucherState($val['voucher_id'], $order_id);
//代金券使用提醒
$message = new MessageModel();
$message->sendMessage('The use of vouchers to remind', Perm::$userId, Perm::$row['user_account'], NULL, $shop_name = NULL, 0, MessageModel::USER_MESSAGE);
$flag = $flag && $flag6;
}
}
//生成订单商品信息(order_goods)
$flag2 = $Order_GoodsModel->addGoods($order_goods_row);
//生成交易快照
$Order_GoodsSnapshot->addSnapshot($order_goods_snapshot_add_row);
//删除商品库存
$Goods_BaseModel->delStock($v['goods_id'], $v['goods_num']);
//从购物车中删除已生成订单的商品
$CartModel->removeCart($v['cart_id']);
~~~
加价购、满即送等活动商品信息插入订单商品表
将单个店铺订单信息同步到paycenter中,并将paycenter中生成的支付单号写入订单表中
~~~
//支付中心生成订单
$key = Yf_Registry::get('shop_api_key');
$url = Yf_Registry::get('paycenter_api_url');
$shop_app_id = Yf_Registry::get('shop_app_id');
$formvars = array();
$formvars['app_id'] = $shop_app_id;
$formvars['from_app_id'] = Yf_Registry::get('shop_app_id');
$formvars['consume_trade_id'] = $order_row['order_id'];
$formvars['order_id'] = $order_row['order_id'];
$formvars['buy_id'] = Perm::$userId;
$formvars['buyer_name'] = Perm::$row['user_account'];
$formvars['seller_id'] = $order_row['seller_user_id'];
$formvars['seller_name'] = $order_row['seller_user_name'];
$formvars['order_state_id'] = $order_row['order_status'];
$formvars['order_payment_amount'] = $order_row['order_payment_amount'];
$formvars['order_commission_fee'] = $order_row['order_commission_fee'];
$formvars['trade_remark'] = $order_row['order_message'];
$formvars['trade_create_time'] = $order_row['order_create_time'];
$formvars['trade_title'] = $trade_title; //商品名称 - 标题
$rs = get_url_with_encrypt($key, sprintf('%s?ctl=Api_Pay_Pay&met=addConsumeTrade&typ=json',$url), $formvars);
~~~
生成合并支付订单
~~~
//生成合并支付订单
$key = Yf_Registry::get('shop_api_key');
$url = Yf_Registry::get('paycenter_api_url');
$shop_app_id = Yf_Registry::get('shop_app_id');
$formvars = array();
$formvars['inorder'] = $inorder;
$formvars['uprice'] = $uprice;
$formvars['buyer'] = Perm::$userId;
$formvars['trade_title'] = $utrade_title;
$formvars['buyer_name'] = Perm::$row['user_account'];
$formvars['app_id'] = $shop_app_id;
$formvars['from_app_id'] = Yf_Registry::get('shop_app_id');
$rs = get_url_with_encrypt($key, sprintf('%s?ctl=Api_Pay_Pay&met=addUnionOrder&typ=json', $url), $formvars);
~~~
判断订单生成是否成功,如果成功则将信息推送到统计中心添加订单统计,将下单成功信息通过IM推送给商家。订单提交失败,将paycenter中生成的订单删除。
#### 2.支付订单
支付单与订单说明:
用户在店铺A和店铺B中购买了100元的商品a和50元的商品b。这两件商品在结算时同时结算,生成订单Oa和订单Ob。Paycenter中生成150元的合并支付单Uab,100元的合并支付订单Ua,50元的合并支付订单Ub。
用户在店铺C中购买10元的商品c。结算生成订单Oc。Paycenter中生成10元的合并支付订单Uc1(相当于上个例子中的Uab),生成10元的合并支付订单Uc2(相当于上个例子中的Ua或者Ub)。
页面显示
文件路径:\paycenter\controllers\InfoCtl.php
控制器:InfoCtl
方法:pay()
视图文件:\paycenter\views\default\InfoCtl\pay.php
~~~
//判断用户选择哪种支付方式,如果选择在线支付则调用相应的方法,如果选择账户余额支付则调用money方法
if(online_payway)
{
window.location.href = SITE_URL + "?ctl=Pay&met=" + online_payway + "&trade_id=" + uorder_id;
}
else
{
$.post(SITE_URL + "?ctl=Pay&met=money&typ=json" ,{trade_id:uorder_id},function(data){
if(data.status == 200)
{
window.location.href = data.data.return_app_url + '?ctl=Buyer_Order&met=<?=$order_g_type?>';
}
else
{
$(".loading-msg").html('支付失败,请重新支付!');
window.location.reload();
}
})
}
~~~
文件路径:\paycenter\controllers\PayCtl.php
控制器:PayCtl.php
方法:money()
~~~
//获取合并订单号的信息
$uorder = $Union_OrderModel->getOne($trade_id);
//判断订单状态是否为等待付款状态
if($uorder['order_state_id'] == Order_StateModel::ORDER_WAIT_PAY)
{
$pay_flag = false;
$pay_user_id = 0;
//判断当前用户是否是下单者,并且订单状态是否是待付款状态
if($uorder['buyer_id'] == Perm::$userId)
{
$pay_flag = true;
$pay_user_id = $uorder['buyer_id'];
}
else
{
//判断当前用户是否是下单者的主管账户
$key = Yf_Registry::get('shop_api_key');
$url = Yf_Registry::get('shop_api_url');
$shop_app_id = Yf_Registry::get('shop_app_id');
$formvars = array();
$formvars['app_id'] = $shop_app_id;
$formvars['user_id'] = Perm::$userId;
$formvars['sub_user_id'] = $uorder['buyer_id'];
$sub_user = get_url_with_encrypt($key, sprintf('%s?ctl=Api_User_Info&met=checkSubUser&typ=json',$url), $formvars);
if(!empty($sub_user['data']) && $sub_user['status'] == 200)
{
$pay_flag = true;
$pay_user_id = Perm::$userId;
}
}
if($pay_flag)
{
//修改订单表中的各种状态
$flag = $Consume_DepositModel->notifyShop($trade_id,$pay_user_id);
if ($flag['status'] == 200)
{
//查找回调地址
$User_AppModel = new User_AppModel();
$user_app = $User_AppModel->getOne($uorder['app_id']);
$return_app_url = $user_app['app_url'];
$data['return_app_url'] = $return_app_url;
$msg = 'success';
$status = 200;
}
else
{
$msg = _('failure');
$status = 250;
}
}
else
{
$msg = _('failure');
$status = 250;
}
}
~~~
文件路径:\paycenter\controllers\PayCtl.php
控制器:PayCtl.php
方法:alipay()
~~~
//判断订单状态是否为等待付款状态
if($trade_row['order_state_id'] == Order_StateModel::ORDER_WAIT_PAY)
{
$pay_flag = false;
$pay_user_id = 0;
//判断当前用户是否是下单者,并且订单状态是否是待付款状态
if($trade_row['buyer_id'] == Perm::$userId)
{
$pay_flag = true;
$pay_user_id = $trade_row['buyer_id'];
}
else
{
//判断当前用户是否是下单者的主管账户
$key = Yf_Registry::get('shop_api_key');
$url = Yf_Registry::get('shop_api_url');
$shop_app_id = Yf_Registry::get('shop_app_id');
$formvars = array();
$formvars['app_id'] = $shop_app_id;
$formvars['user_id'] = Perm::$userId;
$formvars['sub_user_id'] = $trade_row['buyer_id'];
$sub_user = get_url_with_encrypt($key, sprintf('%s?ctl=Api_User_Info&met=checkSubUser&typ=json',$url), $formvars);
if(!empty($sub_user['data']) && $sub_user['status'] == 200)
{
$pay_flag = true;
$pay_user_id = Perm::$userId;
}
}
//ignore 给webpos使用
if($pay_flag || $_GET['ignore']=='abc' )
{
if ($trade_row)
{
$Payment = PaymentModel::create('alipay');
$Payment->pay($trade_row);
}
else
{
echo"<script>alert('支付失败,请重新支付');history.go(-1);</script>";
}
}
else
{
echo"<script>alert('支付失败,请重新支付');history.go(-1);</script>";
}
}
~~~
文件路径:F:\www\paycenter\paycenter\models\Consume\DepositModel.php
方法:notifyShop($order_id = null,$user_id = null)
1.修改paycenter中订单的信息
~~~
//修改合并订单中的订单支付状态
//获取合并支付订单信息
$union_order = $Union_OrderModel->getOne($order_id);
//判断该订单是否是白条支付
$bt_flag = $this->checkBt(array('trade_payment_amount'=>$union_order['trade_payment_amount'],'payment_channel_id'=>$union_order['payment_channel_id']));
//检测支付金额是否正确,判断该订单是否是白条支付
if (($union_order['trade_payment_amount'] == $union_order['union_online_pay_amount'] + $union_order['union_money_pay_amount'] + $union_order['union_cards_pay_amount']) || $bt_flag)
{
略
}
~~~
如果是合并支付的订单,则需要将属于它的单个合并支付单修改状态
~~~
if(count($order_id) > 1)
{
//修改单个合并订单状态
$uorder_row = $Union_OrderModel->getByWhere(array('inorder:IN' => $order_id));
$uorder_id_row = array_column($uorder_row,'union_order_id');
$edit_uorder_row = array();
$edit_uorder_row['order_state_id'] = Order_StateModel::ORDER_PAYED;
$edit_uorder_row['pay_time'] = date('Y-m-d H:i:s');
check_rs($Union_OrderModel->editUnionOrder($uorder_id_row,$edit_uorder_row), $rs_row);
}
~~~
修改订单表中的交易状态
修改交易明细中的订单状态
根据支付情况修改用户资金信息
~~~
if($union_order['union_money_pay_amount'] > 0)
{
//修改用户的资源状态
$User_ResourceModel = new User_ResourceModel();
//1.用户资源中订单金额冻结(现金)
$flag = $User_ResourceModel->frozenUserMoney($user_id,$union_order['union_money_pay_amount']);
check_rs($flag, $rs_row);
}
if($union_order['union_cards_pay_amount'] > 0)
{
$User_ResourceModel = new User_ResourceModel();
//2.用户资源中订单金额冻结(卡)
$flag = $User_ResourceModel->frozenUserCards($user_id,$union_order['union_cards_pay_amount']);
check_rs($flag, $rs_row);
}
//修改白条余额
if($bt_flag)
{
$User_ResourceModel = new User_ResourceModel();
$user_credit_availability = $union_order['trade_payment_amount']*(-1);
$flag = $User_ResourceModel->editResource($user_id,array('user_credit_availability'=>$user_credit_availability),true);
check_rs($flag, $rs_row);
}
~~~
2.paycenter中订单修改完成后,修改shop中的订单信息
付款成功后对买家极光推送
订单付款成功后对卖家进行极光推送
~~~
//根据订单来源,修改shop订单状态
$consume_record = $Consume_TradeModel->getOne($order_id);
$app_id = $consume_record['app_id'];
$User_AppModel = new User_AppModel();
$app_row = $User_AppModel->getOne($app_id);
$key = $app_row['app_key'];
$url = $app_row['app_url'];
$shop_app_id = $app_id;
$formvars = array();
$formvars = $_POST;
$formvars['app_id'] = $shop_app_id;
$formvars['order_id'] = $order_id;
$formvars['uorder_id'] = $uorder_id;
if($consume_record['payment_channel_id'] == Payment_ChannelModel::BAITIAO){
$formvars['payment_channel_code'] = 'baitiao';
}else{
$formvars['payment_channel_code'] = '';
}
$rs = get_url_with_encrypt($key, sprintf('%s?ctl=Api_Trade_Order&met=editOrderRowSatus&typ=json', $url), $formvars);
return $rs;
~~~
#### 3.商家发货
地址链接:/index.php?ctl=Seller_Trade_Order&met=send&typ=e&order_id=订单编号
文件路径:\shop\controllers\Seller\Trade\OrderCtl.php
控制器:OrderCtl
方法:send()
视图文件:\shop\views\default\Seller\Trade\OrderCtl\send.php
根据typ判断该方法是用来显示页面,还是修改订单状态。
~~~
if ($typ == 'e')
{
显示页面
}
else
{
修改订单状态
}
~~~
显示页面部分
~~~
$condi['order_id'] = $order_id;
$data = $Order_BaseModel->getOrderList($condi);
$data = pos($data['items']);
//默认物流公司 url
$default_express_url = Yf_Registry::get('url') . '?ctl=Seller_Trade_Deliver&met=express&typ=e';
//打印运单URL
$print_tpl_url = Yf_Registry::get('url') . '?ctl=Seller_Trade_Waybill&met=printTpl&typ=e&order_id=' . $order_id;
//默认物流公司
$express_list = $Shop_ExpressModel->getDefaultShopExpress();
if(is_array($express_list) && $express_list){
$express_list = array_values($express_list);
}
include $this->view->getView();
~~~
修改订单状态部分
~~~
//判断该笔订单是否是自己的单子
$order_base = $Order_BaseModel->getOne($order_id);
//判断账号是否可以发货
$check_send = $this->checkSend($order_base['seller_user_id'],$order_base['shop_id']);
if($check_send && $order_base['order_status'] < Order_StateModel::ORDER_RECEIVED)
{
//将发货信息添加到订单表中
$edit_flag = $Order_BaseModel->editBase($order_id, $update_data);
//修改订单商品信息
$order_list = $Order_GoodsModel -> getByWhere(array('order_id' => $order_base['order_source_id'],'order_goods_source_id' => ''));
if(!empty($order_list) && $order_base['order_source_id']){
foreach ($order_list as $key => $value) {
$edit_flag1 = $Order_GoodsModel -> editGoods($key,array('order_goods_source_ship' => $update_data['order_shipping_code'].'-'.$update_data['order_shipping_express_id']));
check_rs($edit_flag1,$rs_row);
}
}
//远程修改paycenter中的订单信息
$key = Yf_Registry::get('shop_api_key');
$url = Yf_Registry::get('paycenter_api_url');
$shop_app_id = Yf_Registry::get('shop_app_id');
$formvars = array();
$formvars['order_id'] = $order_id;
$formvars['app_id'] = $shop_app_id;
$rs = get_url_with_encrypt($key, sprintf('%s?ctl=Api_Pay_Pay&met=sendOrderGoods&typ=json', $url), $formvars);
}
~~~
如果订单信息修改正确,发送站内信。
#### 4.确认收货
地址路径:index.php?ctl=Buyer_Order&met=confirmOrder&user=buyer
控制器文件路径:\shop\controllers\Buyer\OrderCtl.php
控制器:Buyer_OrderCtl
方法:confirmOrder()
判断下单者是否是当前用户,订单状态是否为已发货状态
~~~
$order_base['buyer_user_id'] == Perm::$userId && $order_base['order_status'] == Order_StateModel::ORDER_WAIT_CONFIRM_GOODS
~~~
判断是否是货到付款订单,如果是货到付款订单,则将支付时间改为确认收货时间
~~~
if($order_base['payment_id'] == PaymentChannlModel::PAY_CONFIRM)
{
$condition['payment_time'] = get_date_time();
}
~~~
修改订单商品表中的订单状态
~~~
$edit_row['order_goods_status'] = Order_StateModel::ORDER_FINISH;
$order_goods_id = $Order_GoodsModel->getKeyByWhere(array('order_id' => $order_id));
$edit_flag1 = $Order_GoodsModel->editGoods($order_goods_id, $edit_row);
~~~
货到付款修改商品销量
修改paycenter中的订单状态
~~~
$key = Yf_Registry::get('shop_api_key');
$url = Yf_Registry::get('paycenter_api_url');
$shop_app_id = Yf_Registry::get('shop_app_id');
$formvars = array();
$formvars['order_id'] = $order_id;
$formvars['app_id'] = $shop_app_id;
$formvars['from_app_id'] = Yf_Registry::get('shop_app_id');
//判断订单是否是货到付款订单,货到付款订单不需要修改卖家资金
if($order_base['payment_id'] == PaymentChannlModel::PAY_CONFIRM)
{
$formvars['payment'] = 0;
}
$rs = get_url_with_encrypt($key, sprintf('%s?ctl=Api_Pay_Pay&met=confirmOrder&typ=json', $url), $formvars);
~~~
判断用户该笔订单是否存在退款,如果有的话添加商家的退款流水
~~~
$rs = get_url_with_encrypt($key, sprintf('%s?ctl=Api_Pay_Pay&met=refundShopTransfer&typ=json', $url), $formvars);
~~~
计算本次确认收货,用户将获取的积分与成长值
判断用户是否需要升级
~~~
$res_flag = $User_GradeModel->upGrade(Perm::$userId, $resource_row['user_growth']);
~~~
修改用户积分与成长值之后添加记录
~~~
//积分
$points_row['user_id'] = Perm::$userId;
$points_row['user_name'] = Perm::$row['user_account'];
$points_row['class_id'] = Points_LogModel::ONBUY;
$points_row['points_log_points'] = $user_points;
$points_row['points_log_time'] = get_date_time();
$points_row['points_log_desc'] = '确认收货';
$points_row['points_log_flag'] = 'confirmorder';
$Points_LogModel = new Points_LogModel();
$Points_LogModel->addLog($points_row);
//成长值
$grade_row['user_id'] = Perm::$userId;
$grade_row['user_name'] = Perm::$row['user_account'];
$grade_row['class_id'] = Grade_LogModel::ONBUY;
$grade_row['grade_log_grade'] = $user_grade;
$grade_row['grade_log_time'] = get_date_time();
$grade_row['grade_log_desc'] = '确认收货';
$grade_row['grade_log_flag'] = 'confirmorder';
$Grade_LogModel = new Grade_LogModel;
$Grade_LogModel->addLog($grade_row);
~~~
确认收货成功之后,将信息添加到统计中心。
#### 5.评价订单
页面链接:/index.php?ctl=Buyer_Order&met=evaluation&act=add&order_id=订单编号
控制器文件路径:\shop\controllers\Buyer\OrderCtl.php
控制器:Buyer_OrderCtl
方法:evaluation()
根据传递的参数act,判断是追加评价,初次评价还是显示评价列表页
~~~
if ($act == 'again')
{
//追加评价
//获取已评价信息
$data = $Goods_EvaluationModel->getOne($evaluation_goods_id);
//商品信息
$data['goods_base'] = current($Order_GoodsModel->getByWhere(array('goods_id'=>$data['goods_id'],'order_id'=>$data['order_id'])));
//订单信息
$data['order_base'] = $Order_BaseModel->getOne($data['order_id']);
//评价用户的信息
$data['user_info'] = $User_InfoModel->getOne($data['order_base']['buyer_user_id']);
if ('json' == $this->typ)
{
return $this->data->addBody(-140, $data);
}
else
{
$this->view->setMet('evalagain');
}
}
elseif ($act == 'add')
{
//初次评价
//订单信息
$data['order_base'] = $Order_BaseModel->getOne($order_id);
//评价用户的信息
$data['user_info'] = $User_InfoModel->getOne($data['order_base']['buyer_user_id']);
//店铺信息
$data['shop_base'] = $Shop_BaseModel->getOne($data['order_base']['shop_id']);
//查找出订单中的商品
$order_goods_id_row = $Order_GoodsModel->getKeyByWhere(array('order_id' => $order_id));
//商品信息
foreach ($order_goods_id_row as $ogkey => $order_good_id)
{
$data['order_goods'][] = $Order_GoodsModel->getOne($order_good_id);
}
if ('json' == $this->typ)
{
return $this->data->addBody(-140, $data);
}
else
{
$this->view->setMet('evaladd');
}
}
else
{
//显示评价列表页面
//获取买家的所有评论
$user_id = Perm::$userId;
$goods_evaluation_row = array();
$goods_evaluation_row['user_id'] = $user_id;
$data = $Goods_EvaluationModel->getEvaluationByUser($goods_evaluation_row, array(), $page, $rows);
}
~~~
1.初次评价
方法链接:index.php?ctl=Goods_Evaluation&met=addGoodsEvaluation&typ=json
控制器文件:\shop\controllers\Goods\EvaluationCtl.php
控制器:Goods_EvaluationCtl
方法:addGoodsEvaluation()
循环商品评价
~~~
foreach($evaluation as $key => $val)
{
//订单商品信息
$order_goods = $Order_GoodsModel->getOne($val[0]);
//商品信息
$goods_base = $Goods_BaseModel->getOne($order_goods['goods_id']);
//订单信息
$order_base = $Order_BaseModel->getOne($order_goods['order_id']);
//有违禁词
if (Text_Filter::checkBanned($val[3], $matche_row))
{
$data = array();
$msg = __('含有违禁词');
$status = 250;
$this->data->addBody(-140, array(), $msg, $status);
return false;
}
//修改商品的评价
$evaluation_num = $this->goodsEvaluationModel->countGoodsEvaluation($order_goods['goods_id']);
//星级好评数
$goods_evaluation_good_star = ceil(($evaluation_num * $goods_base['goods_evaluation_good_star'] + $val[1]) / ($evaluation_num * 1 + 1));
$goods_evaluation_count = $evaluation_num * 1 + 1;
$edit_row = array();
$edit_row['goods_evaluation_good_star'] = $goods_evaluation_good_star;
$edit_row['goods_evaluation_count'] = $goods_evaluation_count;
$Goods_BaseModel->editBaseFalse($order_goods['goods_id'], $edit_row);
//修改商品common表中的评论数量
$edit_common_row['common_evaluate'] = 1;
$Goods_CommonModel->editCommonTrue($order_goods['common_id'],$edit_common_row);
//插入商品评价表
$flag = $this->goodsEvaluationModel->addEvalution($add_row);
if($flag)
{
/********************************************************/
//评价成功添加数据到统计中心 商品评分
$analytics_data = array(
'product_id'=>$goods_base['goods_id'],
'shop_id'=>$goods_base['shop_id'],
'score'=>$goods_evaluation_good_star,
);
Yf_Plugin_Manager::getInstance()->trigger('analyticsScore',$analytics_data);
/********************************************************/
}
//修改订单商品表
$edit_order_goods['order_goods_evaluation_status'] = Order_GoodsModel::EVALUATION_YES;
$Order_GoodsModel->editGoods($val[0], $edit_order_goods);
}
~~~
添加店铺评价
~~~
$Shop_EvaluationModel->addEvaluation($add_shop_row);
/********************************************************/
//评价成功添加数据到统计中心 店铺评分
$analytics_data = array(
'shop_id'=>$order_base['shop_id']
);
Yf_Plugin_Manager::getInstance()->trigger('analyticsShopCredit',$analytics_data);
/********************************************************/
//修改订单中的评价信息
$edit_order['order_buyer_evaluation_status'] = Order_BaseModel::BUYER_EVALUATE_YES;
$edit_order['order_buyer_evaluation_time'] = get_date_time();
$Order_BaseModel->editBase($order_base['order_id'], $edit_order);
~~~
评价成功后,修改用户的积分及成长值。
2.追加评价
方法链接:index.php?ctl=Goods_Evaluation&met=againGoodsEvaluation&typ=json
控制器文件:\shop\controllers\Goods\EvaluationCtl.php
控制器:Goods_EvaluationCtl
方法:againGoodsEvaluation()
获取追加评价的商品的初次评价信息
~~~
$evaluation_base = $this->goodsEvaluationModel->getOne($evaluation_goods_id);
~~~
判断是否存在违禁词
~~~
if (Text_Filter::checkBanned($content, $matche_row))
{
$data = array();
$msg = __('含有违禁词');
$status = 250;
$this->data->addBody(-140, array(), $msg, $status);
return false;
}
~~~
修改商品评价数
~~~
$edit_row['goods_evaluation_count'] = $goods_evaluation_count;
$Goods_BaseModel = new Goods_BaseModel();
$edit_flag = $Goods_BaseModel->editBase($goods_id, $edit_row);
~~~
插入商品评价表
~~~
$add_flag = $this->goodsEvaluationModel->addEvalution($add_row);
~~~
修改订单商品表中商品的评价状态
~~~
$og_update_flag = $order_goods_model->editGoods($order_goods_id, ['order_goods_evaluation_status'=> Order_GoodsModel::EVALUATION_AGAIN]);
~~~
追加评价成功后,修改用户的积分及成长值。
#### 5.买家取消订单
方法路径:index.php?ctl=Buyer_Order&met=orderCancel&user=buyer
文件路径:\shop\controllers\Buyer\OrderCtl.php
控制器:Buyer_OrderCtl
方法:orderCancel()
根据typ判断是显示页面,还是操作
~~~
if ($typ == 'e')
{
//显示页面
$cancel_row['cancel_identity'] = Order_CancelReasonModel::CANCEL_BUYER;
//获取取消原因
$Order_CancelReasonModel = new Order_CancelReasonModel;
$reason = array_values($Order_CancelReasonModel->getByWhere($cancel_row));
include $this->view->getView();
}
else
{
处理取消订单
}
~~~
处理取消订单
获取订单详情,判断订单的状态与下单者是否是当前用户
~~~
$order_base = $Order_BaseModel->getOne($order_id);
//加入货到付款订单取消功能
if( ($order_base['payment_id'] == PaymentChannlModel::PAY_CONFIRM
&& $order_base['order_status'] == Order_StateModel::ORDER_WAIT_PREPARE_GOODS) //货到付款+等待发货
|| $order_base['order_status'] == Order_StateModel::ORDER_WAIT_PAY
&& $order_base['buyer_user_id'] == Perm::$userId)
{
}
~~~
修改订单信息
~~~
//订单状态
$condition['order_status'] = Order_StateModel::ORDER_CANCEL;
//订单取消原因
$condition['order_cancel_reason'] = addslashes($state_info);
//订单取消者身份
$condition['order_cancel_identity'] = Order_BaseModel::IS_BUYER_CANCEL;
//订单取消时间
$condition['order_cancel_date'] = get_date_time();
$edit_flag = $Order_BaseModel->editBase($order_id, $condition);
~~~
修改订单商品信息
~~~
//订单商品状态
$edit_row['order_goods_status'] = Order_StateModel::ORDER_CANCEL;
$order_goods_id = $Order_GoodsModel->getKeyByWhere(array('order_id' => $order_id));
$edit_flag1 = $Order_GoodsModel->editGoods($order_goods_id, $edit_row);
~~~
修改商品库存
修改paycenter中的订单状态
~~~
$rs = get_url_with_encrypt($key, sprintf('%s?ctl=Api_Pay_Pay&met=cancelOrder&typ=json', $url), $formvars);
~~~
判断订单是否使用平台红包,如果使用,将平台红包状态改为未使用
~~~
//判断订单是否使用平台红包,如果使用,将平台红包状态改为未使用
$RedPacket_BaseModel = new RedPacket_BaseModel();
$red_data = $RedPacket_BaseModel->getOneByWhere(['redpacket_order_id'=>$order_base['order_id']]);
if($red_data)
{
$red_flag = $RedPacket_BaseModel->editRedPacket($red_data['redpacket_id'], ['redpacket_state'=>RedPacket_BaseModel::UNUSED]);
}
~~~
订单取消成功,加入统计中心
- 序言
- 系统要求
- 版本更新日志
- 远丰商城技术对接说明
- 开发指导
- 系统架构
- 负载集群
- 云存储
- 框架内容
- 基础
- 开发规范
- 目录结构
- 架构
- 架构总览
- 数据库
- 数据库连接
- 基本使用
- 缓存
- 配置
- 路由
- 数据字典
- ucenter
- shop
- paycenter
- ucenter_admin
- shop_admin
- paycenter_admin
- shop1
- shop2
- shop3
- 通讯内容
- 商家中心
- 顶部导航栏
- 店铺信息栏
- 店铺及商品提示栏
- 交易提示栏
- 销售情况统计栏
- 集群架构图
- 单品销量排行栏
- 店铺运营推广栏
- 平台联系方式栏
- 订单物流
- 商品
- 商品列表
- 商品详情
- 商品发布与编辑
- 分销商品
- 关联版式
- 商品规格
- 图片空间
- 淘宝导入
- 订单流程
- 交易订单
- 订单退款/退货
- 促销
- 团购管理
- 加价购
- 限时折扣
- 满即送
- 代金券管理
- 分销
- 店铺
- 店铺设置
- 自销产品供应商
- 实体店铺
- 品牌申请
- 店铺信息
- 消费者保障服务
- 门店账号
- 分销商--产品供应商
- 分销明细
- 批发市场
- 商家微信公众号
- 售后服务
- 咨询管理
- 投诉管理
- 退款管理
- 退货管理
- 杂项
- 远程上传图片
- 接口(废弃,参考最外层接口项)
- 接口说明
- 品牌
- 商品规格
- 商品类型
- 商品分类
- 商品
- 订单
- 商品/店铺收藏
- 足迹
- 退款及退货
- 商家店铺
- 会员
- 入驻协议
- 订单接口
- 商品接口
- 订单物流接口
- 商家中心接口
- 促销接口
- 快递鸟物流接口
- 代金券接口
- 首页版块
- 团购
- 平台红包
- 限时折扣接口
- 拼团接口
- wap首页模板
- JS
- 银联支付
- 多语言
- 商品评分
- 图片加载
- 买家申请退款退货
- 商家退款退货
- 平台退款退货
- 添加发票
- 提交订单
- 确认订单
- 运费销售区域
- 获取会员地址
- 充值
- 导出XLS
- 商城系统集成
- 多语言实现
- 三级分销推广链接发展推广员
- app.ini.php
- 去分销
- 版本更新
- 物流支持
- 运营人员建议
- 业务逻辑
- 统计结算
- 客服消息
- 账号
- 三级分销
- IM
- 配置
- 平台帐号
- 活动数据表说明
- 接口
- 数据库中间键
- MyCat的优势
- 概念说明
- Mycat的下载及安装
- 参数配置案列
- Mycat读写分离
- 基本命令
- 常见错误