订单详情解耦、测试订单推送
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
meng 2023-02-24 04:56:30 +08:00
parent 82436da0c9
commit eebdf69ab7
5 changed files with 506 additions and 86 deletions

View File

@ -38,6 +38,11 @@ steps:
- /bin/cp -f /www/wwwroot/we.cnp5.cn/addons/ewei_shopv2/ewei_shopv2_api.php /www/wwwroot/we.cnp5.cn/app/ewei_shopv2_api.php
- /bin/cp -f /www/wwwroot/we.cnp5.cn/addons/ewei_shopv2/api.php /www/wwwroot/we.cnp5.cn/app/api.php
- name: "复制PC端目录"
commands:
- echo "复制pcsite到根目录"
- /bin/cp -rf /www/wwwroot/we.cnp5.cn/addons/ewei_shopv2/pcsite/ /www/wwwroot/we.cnp5.cn/pcsite
- name: "更新数据库"
commands:
- curl 'http://we.cnp5.cn/app/api.php?i=1&r=upsql&sql_key=wanshangliaoliao' --compressed --insecure

View File

@ -1,4 +1,5 @@
<?php
namespace core\job;
class sendPostera
@ -10,11 +11,10 @@ class sendPostera
public function __construct($config = array())
{
if (!empty($config)){
if (!empty($config)) {
foreach ($config as $name => $value) {
$this->$name = $value;
}
}
}
@ -25,11 +25,11 @@ class sendPostera
$openid = $this->openid;
$content = $this->content;
//用户
if(empty($openid)){
if (empty($openid)) {
return;
}
$member = m('member')->getMember($openid);
if(empty($member)){
if (empty($member)) {
return;
}
@ -40,56 +40,55 @@ class sendPostera
return;
}
$time = time();
if($poster['timestart']>$time){
$starttext =empty($poster['starttext'])?"活动于 [starttime] 开始,请耐心等待...":$poster['starttext'];
$starttext =str_replace("[starttime]",date('Y年m月d日 H:i',$poster['timestart']),$starttext);
$starttext =str_replace("[endtime]",date('Y年m月d日 H:i',$poster['timeend']),$starttext);
m('message')->sendCustomNotice($openid,$starttext);
if ($poster['timestart'] > $time) {
$starttext = empty($poster['starttext']) ? "活动于 [starttime] 开始,请耐心等待..." : $poster['starttext'];
$starttext = str_replace("[starttime]", date('Y年m月d日 H:i', $poster['timestart']), $starttext);
$starttext = str_replace("[endtime]", date('Y年m月d日 H:i', $poster['timeend']), $starttext);
m('message')->sendCustomNotice($openid, $starttext);
return;
}
if( $poster['timeend']<time()){
$endtext = empty($poster['endtext'])?"活动已结束,谢谢您的关注!":$poster['endtext'];
$endtext =str_replace("[starttime]",date('Y-m-d H:i',$poster['timestart']),$endtext);
$endtext =str_replace("[endtime]",date('Y-m-d- H:i',$poster['timeend']),$endtext);
if ($poster['timeend'] < time()) {
$endtext = empty($poster['endtext']) ? "活动已结束,谢谢您的关注!" : $poster['endtext'];
$endtext = str_replace("[starttime]", date('Y-m-d H:i', $poster['timestart']), $endtext);
$endtext = str_replace("[endtime]", date('Y-m-d- H:i', $poster['timeend']), $endtext);
m('message')->sendCustomNotice($openid,$endtext);
m('message')->sendCustomNotice($openid, $endtext);
return;
}
if ($member['isagent'] != 1 || $member['status'] != 1) {
//如果不分销商
if (empty($poster['isopen']) ) {
if (empty($poster['isopen'])) {
$opentext = !empty($poster['opentext'])?htmlspecialchars_decode($poster['opentext'],ENT_QUOTES):'您还不是我们分销商,去努力成为分销商,拥有你的专属海报吧!';
$opentext = !empty($poster['opentext']) ? htmlspecialchars_decode($poster['opentext'], ENT_QUOTES) : '您还不是我们分销商,去努力成为分销商,拥有你的专属海报吧!';
m('message')->sendCustomNotice($openid, $opentext, trim($poster['openurl']));
return;
}
}
$waittext = !empty($poster['waittext'])?htmlspecialchars_decode($poster['waittext'],ENT_QUOTES):'您的专属海报正在拼命生成中,请等待片刻...';
$waittext =str_replace("[starttime]",date('Y年m月d日 H:i',$poster['timestart']),$waittext);
$waittext =str_replace("[endtime]",date('Y年m月d日 H:i',$poster['timeend']),$waittext);
$waittext = !empty($poster['waittext']) ? htmlspecialchars_decode($poster['waittext'], ENT_QUOTES) : '您的专属海报正在拼命生成中,请等待片刻...';
$waittext = str_replace("[starttime]", date('Y年m月d日 H:i', $poster['timestart']), $waittext);
$waittext = str_replace("[endtime]", date('Y年m月d日 H:i', $poster['timeend']), $waittext);
m('message')->sendCustomNotice($openid, $waittext);
//获取二维码图片
//获取二维码图片
$qr = p('postera')->getQR($poster, $member);
if (is_error($qr)) {
m('message')->sendCustomNotice($openid, '生成二维码出错: ' . $qr['message']);
return;
}
//生成海报
//生成海报
$img = p('postera')->createPoster($poster, $member, $qr);
$mediaid = $img['mediaid'];
if(!empty($mediaid)){
if (!empty($mediaid)) {
//发送海报
m('message')->sendImage($openid,$mediaid);
}
else{
$oktext= "<a href='".$img['img']."'>点击查看您的专属海报</a>";
m('message')->sendImage($openid, $mediaid);
} else {
$oktext = "<a href='" . $img['img'] . "'>点击查看您的专属海报</a>";
m('message')->sendCustomNotice($openid, $oktext);
}
}

View File

@ -29,7 +29,12 @@ class Wpfw_EweiShopV2Model {
if(empty($wpset)){
return array('wpfw_url'=>$sysset['default_url'],'wpfw_api_key'=>$sysset['api_key']);
}else{
return array('wpfw_url'=>$wpset['url'],'wpfw_api_key'=>$wpset['api_key']);
if($wpset['wpfw_type'] == 0){
return array('wpfw_url'=>'','wpfw_api_key'=>'');
}else{
return array('wpfw_url'=>$wpset['url'],'wpfw_api_key'=>$wpset['api_key']);
}
}
}
public function good_set_wpset($goods_id,$url,$api_key)
@ -56,5 +61,427 @@ class Wpfw_EweiShopV2Model {
}
}
/**
* 生成签名sign
* @param array $params 参数
* @param string $apiKey API密钥
* @return string sign
*/
public function generateSign($params, $apiKey)
{
unset($params['sign']);
//所有请求参数按照字母先后顺序排
ksort($params);
//定义字符串开始所包括的字符串
$stringToBeSigned = $apiKey.'&';
//把所有参数名和参数值串在一起
foreach ($params as $k => $v)
{
$stringToBeSigned .= '&'.urldecode($k.'='.$v);
}
unset($k, $v);
//使用MD5进行加密再转化成大写
$sign = strtoupper(md5($stringToBeSigned));
$params['sign'] = $sign;
var_dump($stringToBeSigned);
return $params;
}
public function order_post($order_id = null, $order_sn = null)
{
global $_W;
$order_info = $this->get_order_info($order_id,$order_sn);
if($order_info['error'] != 0){
return array('msg' => "参数错误,未找到订单!", 'error' => 552001);
}
//保存推送结果
$data = array();
//todo:订单的商品
$goods = $order_info['order']['goods'];
if(empty($goods)){
return array('msg' => "参数错误,未找到订单下的商品!", 'error' => 552001);
}
foreach($goods as $item){
$data['id'] = $item['id'];
$set = $this->good_get_wpset($item['id']);
$data['wpfw'] = $set;
if(!empty($set['wpfw_url'])){
$info = json_encode($order_info['order']);
$res = ihttp_post($set['wpfw_url'],$this->generateSign(array('order'=>$info),$set['wpfw_api_key']));
var_dump($res);
}
}
}
/**
* 获取商品详情
*/
public function get_order_info($order_id = null, $order_sn = null)
{
global $_W, $_GPC;
$uniacid = $_W['uniacid'];
if (empty($order_id) && empty($order_sn)) {
return array('msg' => "参数错误订单号或ID为空", 'error' => 552000);
}
if (!empty($order_id)) {
$order = pdo_fetch("select * from " . tablename('ewei_shop_order') . ' where id=:id and uniacid=:uniacid limit 1', array(':id' => $order_id, ':uniacid' => $uniacid));
} else {
$order = pdo_fetch("select * from " . tablename('ewei_shop_order') . ' where ordersn=:ordersn and uniacid=:uniacid limit 1', array(':ordersn' => $order_sn, ':uniacid' => $uniacid));
}
if (empty($order)) {
return array('msg' => "参数错误,未找到订单!", 'error' => 552001);
}
$ispeerpay = m('order')->checkpeerpay($order['id']); //检查是否是代付订单
$orderid = $order['id'];
if ($order['paytype'] == 3 || !empty($order['storeid'])) {
$trade = m('common')->getSysset('trade');
if (empty($trade['freightText'])) {
$trade['freightText'] = '含运费';
}
}
//是不是记次
$isonlyverifygoods = m('order')->checkisonlyverifygoods($order['id']);
if ($order['merchshow'] == 1) {
return array('msg' => "参数错误,未找到订单!", 'error' => 552002);
}
if ($order['userdeleted'] == 2) {
return array('msg' => "参数错误,未找到订单!", 'error' => 552000);
}
//todo:自定义表单
$diyform_plugin = p('diyform');
$diyformfields = "";
if ($diyform_plugin) {
$diyformfields = ",og.diyformfields,og.diyformdata";
}
$param = array();
$param[':uniacid'] = $_W['uniacid'];
if ($order['isparent'] == 1) {
$scondition = " og.parentorderid=:parentorderid";
$param[':parentorderid'] = $orderid;
} else {
$scondition = " og.orderid=:orderid";
$param[':orderid'] = $orderid;
}
$goods = pdo_fetchall("select og.id as ordergoodsid,og.single_refundstate,og.sendtime,g.id,g.type, og.goodsid,og.price,g.title,g.thumb,g.status,og.total,g.credit,og.optionid,og.optionname as optiontitle,g.isverify,g.isfullback,g.refund,g.cannotrefund,g.returngoods,g.exchange,g.storeids{$diyformfields} from " . tablename('ewei_shop_order_goods') . " og "
. " left join " . tablename('ewei_shop_goods') . " g on g.id=og.goodsid "
. " where $scondition and og.uniacid=:uniacid ", $param);
$goods = set_medias($goods, array('thumb'));
//商品是否支持退换货
$goodsrefund = true;
$refundgoods = array(
'refund' => true,
'returngoods' => true,
'exchange' => true,
);
if (!empty($goods)) {
$isfullback = false; //全返
$entity = true; //订单全部商品为实体商品
foreach ($goods as &$g) {
if ($g['isfullback']) {
$isfullback = true;
$fullbackgoods = pdo_fetch("SELECT * FROM " . tablename('ewei_shop_fullback_goods') . " WHERE goodsid = :goodsid and uniacid = :uniacid limit 1 ", array(':goodsid' => $g['goodsid'], ':uniacid' => $uniacid));
if ($g['optionid']) {
$option = pdo_fetch("select `day`,allfullbackprice,fullbackprice,allfullbackratio,fullbackratio,isfullback
from " . tablename('ewei_shop_goods_option') . " where id = :id and uniacid = :uniacid ", array(":id" => $g['optionid'], ":uniacid" => $uniacid));
$fullbackgoods['minallfullbackallprice'] = $option['allfullbackprice'];
$fullbackgoods['fullbackprice'] = $option['fullbackprice'];
$fullbackgoods['minallfullbackallratio'] = $option['allfullbackratio'];
$fullbackgoods['fullbackratio'] = $option['fullbackratio'];
$fullbackgoods['day'] = $option['day'];
}
$g['fullbackgoods'] = $fullbackgoods;
unset($fullbackgoods, $option);
}
if (!empty($g['optionid'])) {
$thumb = m('goods')->getOptionThumb($g['goodsid'], $g['optionid']);
if (!empty($thumb)) {
$g['thumb'] = $thumb;
}
}
if (empty($g['cannotrefund'])) {
$g['refund'] = true;
$g['returngoods'] = true;
$g['exchange'] = true;
}
/*虚拟商品,虚拟物品*/
if ((($g['type'] == 2 || $g['type'] == 3) && $g['isverify'] < 2) || $order['status'] <= 0) {
$g['refund'] = false;
$g['returngoods'] = false;
$g['exchange'] = false;
}
if ($order['status'] >= 2) {
//todo:是否可以退款
if (!empty($g['cannotrefund']) && empty($g['refund']) && empty($g['returngoods']) && empty($g['exchange'])) {
$goodsrefund = false;
}
}
if ($order['status'] == 1) {
//todo:是否可以退款
if (!empty($g['cannotrefund']) && empty($g['refund'])) {
$goodsrefund = false;
}
$g['returngoods'] = false;
$g['exchange'] = false;
}
$refundgoods['refund'] = empty($refundgoods['refund']) ? false : $g['refund'];
$refundgoods['returngoods'] = empty($refundgoods['returngoods']) ? false : $g['returngoods'];
$refundgoods['exchange'] = empty($refundgoods['exchange']) ? false : $g['exchange'];
/*判断所有商品全部为实体商品---核销实体商品订单退款*/
if ($g['type'] == 1 && $entity = true) {
$entity = true;
}
}
}
$diyform_flag = 0;
if ($diyform_plugin) {
foreach ($goods as &$g) {
$g['diyformfields'] = iunserializer($g['diyformfields']);
$g['diyformdata'] = iunserializer($g['diyformdata']);
foreach ($g['diyformfields'] as $k => $v) {
if ($v['data_type'] == 5) {
$g['diyformdata'][$k][0] = tomedia($g['diyformdata'][$k][0]);
}
if (isset($g['diyformdata'][$k])) {
$g['diyformdata'][$v['tp_name']] = $g['diyformdata'][$k];
unset($g['diyformdata'][$k]);
}
}
unset($g['diyformfields']);
unset($g);
}
//订单统一模板
if (!empty($order['diyformfields']) && !empty($order['diyformdata'])) {
$order_fields = iunserializer($order['diyformfields']);
$order_data = iunserializer($order['diyformdata']);
}
}
//收货地址
$address = false;
if (!empty($order['addressid'])) {
$address = iunserializer($order['address']);
if (!is_array($address)) {
$address = pdo_fetch('select * from ' . tablename('ewei_shop_member_address') . ' where id=:id limit 1', array(':id' => $order['addressid']));
}
}
//联系人
$carrier = @iunserializer($order['carrier']);
if (!is_array($carrier) || empty($carrier)) {
$carrier = false;
}
//是否可以退款
$canreturn = false;
$tradeset = m('common')->getSysset('trade');
if ($order['status'] == 1) {
$canrefund = $goodsrefund;
} elseif ($order['status'] == 2) {
$canrefund = true;
if ($order['status'] == 2 && $order['price'] == $order['dispatchprice']) {
if ($order['refundstate'] > 0) {
$canrefund = true;
} else {
$canrefund = false;
//当产品余额抵扣所有金额的时候 允许换货
if (!$goodsrefund) {
//当产品不允许退换货而且抵扣了所有金额之后不显示 退款
$canreturn = false;
} else {
$canreturn = true;
}
}
}
} else if ($order['status'] == 3) {
if ($order['isverify'] != 1 && empty($order['virtual'])) { //如果不是核销或虚拟物品,则可以退货
if ($order['refundstate'] > 0) {
$canrefund = true;
} else {
$refunddays = intval($tradeset['refunddays']);
if ($refunddays > 0) {
$days = intval((time() - $order['finishtime']) / 3600 / 24);
if ($days <= $refunddays) {
$canrefund = true;
}
}
}
}
} elseif ($order['status'] == -1 && $order['isverify'] == 1 && $entity) {
/*过期、实体、核销商品可退款*/
$canrefund = true;
}
if ($canrefund && ($refundgoods['refund'] || $refundgoods['returngoods'] || $refundgoods['exchange'])) {
$canrefund = true;
} else {
$canrefund = false;
}
$order['canrefund'] = $canrefund;
$order['statusstr'] = '';
if (empty($order['status'])) {
if ($order['paytype'] == 3) {
$order['statusstr'] = '货到付款,等待发货';
} else {
$order['statusstr'] = '等待付款';
}
} elseif ($order['status'] == 1) {
if ($order['sendtype'] > 0) {
$order['statusstr'] = '部分商品已发货';
} else {
$order['statusstr'] = '买家已付款';
}
} elseif ($order['status'] == 2) {
$order['statusstr'] = '卖家已发货';
} elseif ($order['status'] == 3) {
$order['statusstr'] = '交易完成';
} elseif ($order['status'] == -1) {
$order['statusstr'] = '交易关闭';
}
$newFields = array();
if (is_array($order_fields) && !empty($order_fields)) {
foreach ($order_fields as $k => $v) {
$v['diy_type'] = $k;
$newFields[] = $v;
if ($v['data_type'] == 5 && !empty($order_data[$k]) && is_array($order_data[$k])) {
$order_data[$k] = set_medias($order_data[$k]);
}
}
}
//todo:处理订单的自定义表单 如果订单没有 商品有就用第一个商品的
if (empty($order_data) && !empty($goods[0]['diyformdata'])) {
$order_data = $goods[0]['diyformdata'];
}
$order = array(
'id' => $order['id'],
'ordersn' => $order['ordersn'],
'createtime' => date('Y-m-d H:i:s', $order['createtime']),
'paytime' => !empty($order['paytime']) ? date('Y-m-d H:i:s', $order['paytime']) : '',
'sendtime' => !empty($order['sendtime']) ? date('Y-m-d H:i:s', $order['sendtime']) : '',
'finishtime' => !empty($order['finishtime']) ? date('Y-m-d H:i:s', $order['finishtime']) : '',
'status' => $order['status'],
'statusstr' => $order['statusstr'],
'price' => $order['price'],
'goodsprice' => $order['goodsprice'],
'dispatchprice' => $order['dispatchprice'],
//'ispackage' => $order['ispackage'],
//'invoice_img' => $order['invoice_img'],
'seckilldiscountprice' => $order['seckilldiscountprice'],
'sendtype' => $order['sendtype'],
'deductenough' => $order['deductenough'],
'couponprice' => $order['couponprice'],
'discountprice' => $order['discountprice'],
'isdiscountprice' => $order['isdiscountprice'],
'deductprice' => $order['deductprice'],
'deductcredit2' => $order['deductcredit2'],
//'diyformfields' => empty($newFields) ? array() : $newFields,
'diyformdata' => empty($order_data) ? array() : $order_data,
// 'showverify' => $order['showverify'],
// 'verifytitle' => $order['dispatchtype'] ? '自提码' : '消费码',
// 'dispatchtype' => $order['dispatchtype'],
//'invoicename' => empty($order['invoicename'])?null:m('sale')->parseInvoiceInfo($order['invoicename']),
// 'merchid' => intval($order['merchid']),
// 'virtual' => $order['virtual'],
// 'virtual_str' => $order['status']==3?$order['virtual_str']:'',
// 'virtual_info' => $order['status']==3?$order['virtual_info']:'',
//'isvirtualsend' => $order['isvirtualsend'],
//'virtualsend_info' => empty($order['virtualsend_info'])?'':$order['virtualsend_info'],
'canrefund' => $order['canrefund'],
//'merchdeductenough' => $order['merchdeductenough'],
// 'refundtext' => ($order['status'] == 1 ? '申请售后' : '申请售后') . (!empty($order['refundstate']) ? '中' : ''),
// 'refundtext_btn' => '',
'cancancel' => !$order['userdeleted'] && !$order['status'],
'canpay' => $order['paytype'] != 3 && !$order['userdeleted'] && $order['status'] == 0,
'canverify' => $order['canverify'] && $order['status'] != -1 && $order['status'] != 0,
'candelete' => $order['status'] == 3 || $order['status'] == -1,
'cancomment' => $order['status'] == 3 && $order['iscomment'] == 0 && empty($_W['shopset']['trade']['closecomment']),
'cancomment2' => $order['status'] == 3 && $order['iscomment'] == 1 && empty($_W['shopset']['trade']['closecomment']),
'cancomplete' => $order['status'] == 2,
'cancancelrefund' => $order['refundstate'] > 0/* && isset($refund) && $refund['status'] != 5*/,
'candelete2' => $order['userdeleted'] == 1,
'canrestore' => $order['userdeleted'] == 1,
// 'verifytype' => $order['verifytype'],
'refundstate' => $order['refundstate'],
// 'city_express_state'=>$order['city_express_state'],
// 'iscycelbuy' => $order['iscycelbuy'],
// 'isonlyverifygoods'=>$isonlyverifygoods,
'ramark' => empty($order['remark']) ? '' : $order['remark'],
'goods' => $goods,
);
// $gift = array();
// $nogift = array();
// $gn=0;
// $nog=0;
// $allgoods = array();
// foreach ($goods as &$g) {
// $newFields = array();
// if (is_array($g['diyformfields'])) {
// foreach ($g['diyformfields'] as $k => $v) {
// $v['diy_type'] = $k;
// $newFields[] = $v;
// if(isset($g['diyformdata'][$k])){
// $g['diyformdata'][$v['tp_name']] = $g['diyformdata'][$k];
// unset($g['diyformdata'][$k]);
// }
// }
// }
// $allgoods[] = array(
// 'id' => $g['goodsid'],
// 'title' => $g['title'],
// 'price' => $g['price'],
// 'thumb' => tomedia($g['thumb']),
// 'total' => $g['total'],
// 'refund' => $g['refund'],
// 'returngoods' => $g['returngoods'],
// 'exchange' => $g['exchange'],
// 'isfullback' => $g['isfullback'],
// 'fullbackgoods' => $g['fullbackgoods'],
// 'status' => $g['status'],
// 'optionname' => $g['optiontitle'],
// 'diyformdata' =>empty( $g['diyformdata']) ? array() : $g['diyformdata'],
// //'diyformfields' => $newFields,
// 'ordergoodsid'=>$g['ordergoodsid'],
// 'single_refundstate'=>$g['single_refundstate'],
// 'sendtime'=>$g['sendtime'],
// );
// }
// unset($g);
// if(!empty($allgoods)){
// foreach ($allgoods as $gk => $og){
// if($og['status']==2){
// $gift[$gn] = $og;
// $gn++;
// }else{
// $nogift[$nog] = $og;
// $nog++;
// }
// }
// }
// foreach($gift as $kek=>$val){
// $giftinfo = pdo_fetch("select id,title,thumb,marketprice,total from " . tablename('ewei_shop_goods') . " where uniacid = " . $uniacid . " and status = 2 and id = " . $val['id'] . " ");
// if(empty($giftinfo)||$giftinfo['total'] ==0){
// unset($gift[$kek]);
// }
// }
$order['carrier'] = $carrier;
$result = array(
'error' => 0,
'order' => $order,
//'goods'=>$allgoods,
//'address' => $address,
//'carrier' => $carrier,
'msg' => 'ok',
);
return $result;
}
}

View File

@ -190,7 +190,6 @@ class Refund_EweiShopV2Page extends WebPage {
$item['ordersn'] .= '_wxapp';
$ordersn .= '_wxapp';
$member = m('member')->getMember($item['openid']);
// $item['openid'] = $member['openid_wa'];
$item['apppay'] = 2;
}
//退款金额
@ -367,22 +366,6 @@ class Refund_EweiShopV2Page extends WebPage {
m('order')->fullbackstop($item['id']);
}
//
// //计算订单中商品累计赠送的积分 扣除积分已经在 m('order')->setStocksAndCredits($item['id'], 2); 方法中实现,此处不需要
// $credits = m('order')->getGoodsCredit($goods);
// //订单完成减少积分
// if($item['status'] == 3){
// //扣除会员购物赠送积分
// if($credits>0){
// m('member')->setCredit($item['openid'], 'credit1', -$credits, array(0, $shopset['name'] . "退款扣除购物赠送积分: {$credits} 订单号: " . $item['ordersn']));
// }
// }
//返还抵扣积分
/*if ($item['deductcredit'] > 0) {
m('member')->setCredit($item['openid'], 'credit1', $item['deductcredit'], array('0', $shopset['name'] . "购物返还抵扣积分 积分: {$item['deductcredit']} 抵扣金额: {$item['deductprice']} 订单号: {$item['ordersn']}"));
}*/
if ($dededuct__refund_price > 0) {
$item['deductcredit2'] = $dededuct__refund_price;

View File

@ -753,7 +753,7 @@ class Detail_EweiShopV2Page extends OpenApiMobilePage
//return app_json(array( 'list' => $list, 'pagesize' => $psize, 'total' => $total ,'page'=>$pindex,'can_sync_goodscircle'=>$can_sync_goodscircle));
}
public function detail()
public function info()
{
global $_W, $_GPC;
@ -795,7 +795,7 @@ class Detail_EweiShopV2Page extends OpenApiMobilePage
}
//是不是记次
$isonlyverifygoods = m('order')->checkisonlyverifygoods($order['id']);;
$isonlyverifygoods = m('order')->checkisonlyverifygoods($order['id']);
if (empty($order)) {
return $this->error("参数错误订单号或ID为空", 552000);
@ -845,15 +845,15 @@ class Detail_EweiShopV2Page extends OpenApiMobilePage
'exchange' => true,
);
if (!empty($goods)) {
$isfullback=false;
$entity = true;//订单全部商品为实体商品
$isfullback = false;
$entity = true; //订单全部商品为实体商品
foreach ($goods as &$g) {
if($g['isfullback']){
$isfullback=true;
$fullbackgoods = pdo_fetch("SELECT * FROM ".tablename('ewei_shop_fullback_goods')." WHERE goodsid = :goodsid and uniacid = :uniacid limit 1 ",array(':goodsid'=>$g['goodsid'],':uniacid'=>$uniacid));
if($g['optionid']){
if ($g['isfullback']) {
$isfullback = true;
$fullbackgoods = pdo_fetch("SELECT * FROM " . tablename('ewei_shop_fullback_goods') . " WHERE goodsid = :goodsid and uniacid = :uniacid limit 1 ", array(':goodsid' => $g['goodsid'], ':uniacid' => $uniacid));
if ($g['optionid']) {
$option = pdo_fetch("select `day`,allfullbackprice,fullbackprice,allfullbackratio,fullbackratio,isfullback
from ".tablename('ewei_shop_goods_option')." where id = :id and uniacid = :uniacid ",array(":id"=>$g['optionid'],":uniacid"=>$uniacid));
from " . tablename('ewei_shop_goods_option') . " where id = :id and uniacid = :uniacid ", array(":id" => $g['optionid'], ":uniacid" => $uniacid));
$fullbackgoods['minallfullbackallprice'] = $option['allfullbackprice'];
$fullbackgoods['fullbackprice'] = $option['fullbackprice'];
$fullbackgoods['minallfullbackallratio'] = $option['allfullbackratio'];
@ -861,7 +861,7 @@ class Detail_EweiShopV2Page extends OpenApiMobilePage
$fullbackgoods['day'] = $option['day'];
}
$g['fullbackgoods'] = $fullbackgoods;
unset($fullbackgoods,$option);
unset($fullbackgoods, $option);
}
if (!empty($g['optionid'])) {
$thumb = m('goods')->getOptionThumb($g['goodsid'], $g['optionid']);
@ -869,42 +869,42 @@ class Detail_EweiShopV2Page extends OpenApiMobilePage
$g['thumb'] = $thumb;
}
}
if(empty($g['cannotrefund'])){
$g['refund'] = true ;
if (empty($g['cannotrefund'])) {
$g['refund'] = true;
$g['returngoods'] = true;
$g['exchange'] = true;
}
/*虚拟商品,虚拟物品*/
if ((($g['type']==2 || $g['type']==3) && $g['isverify'] < 2 ) || $order['status'] <= 0){
$g['refund'] = false ;
if ((($g['type'] == 2 || $g['type'] == 3) && $g['isverify'] < 2) || $order['status'] <= 0) {
$g['refund'] = false;
$g['returngoods'] = false;
$g['exchange'] = false;
}
if($order['status']>=2){
if ($order['status'] >= 2) {
/*
* 退款优化V1.10
* 张洪利2019-09-16
* */
if(!empty($g['cannotrefund']) && empty($g['refund']) && empty($g['returngoods']) && empty($g['exchange'])){
$goodsrefund = false ;
}
}
if($order['status']==1){
if (!empty($g['cannotrefund']) && empty($g['refund']) && empty($g['returngoods']) && empty($g['exchange'])) {
$goodsrefund = false;
}
}
if ($order['status'] == 1) {
/*
* 退款优化V1.10
* 张洪利2019-09-16
* */
if(!empty($g['cannotrefund']) && empty($g['refund'])){
$goodsrefund = false ;
if (!empty($g['cannotrefund']) && empty($g['refund'])) {
$goodsrefund = false;
}
$g['returngoods'] = false;
$g['exchange'] = false;
}
$refundgoods['refund'] = empty($refundgoods['refund']) ? false :$g['refund'];
$refundgoods['returngoods'] = empty($refundgoods['returngoods']) ? false :$g['returngoods'];
$refundgoods['exchange'] = empty($refundgoods['exchange']) ? false :$g['exchange'];
$refundgoods['refund'] = empty($refundgoods['refund']) ? false : $g['refund'];
$refundgoods['returngoods'] = empty($refundgoods['returngoods']) ? false : $g['returngoods'];
$refundgoods['exchange'] = empty($refundgoods['exchange']) ? false : $g['exchange'];
/*判断所有商品全部为实体商品---核销实体商品订单退款*/
if($g['type']==1 && $entity = true){
if ($g['type'] == 1 && $entity = true) {
$entity = true;
}
}
@ -1051,14 +1051,14 @@ class Detail_EweiShopV2Page extends OpenApiMobilePage
} else {
$canrefund = false;
//当产品余额抵扣所有金额的时候 允许换货
if(!$goodsrefund){
if (!$goodsrefund) {
//当产品不允许退换货而且抵扣了所有金额之后不显示 退款
$canreturn = false;
}else{
} else {
$canreturn = true;
}
}
}
}
} else if ($order['status'] == 3) {
if ($order['isverify'] != 1 && empty($order['virtual'])) { //如果不是核销或虚拟物品,则可以退货
if ($order['refundstate'] > 0) {
@ -1542,7 +1542,7 @@ class Detail_EweiShopV2Page extends OpenApiMobilePage
return array('id' => $id, 'item' => $item,'is_singlerefund'=>$is_singlerefund);
}
//接口支付
public function pay() {
public function apipay() {
global $_W, $_GPC;
$opdata = $this->opData();
@ -1603,7 +1603,6 @@ class Detail_EweiShopV2Page extends OpenApiMobilePage
//创建记次时商品记录
m('verifygoods')->createverifygoods($item['id']);
plog('order.op.pay', "订单接口确认付款 ID: {$item['id']} 订单号: {$item['ordersn']}");
return $this->success("订单接口确认付款 ID: {$item['id']} 订单号: {$item['ordersn']}");
}
@ -1666,20 +1665,11 @@ class Detail_EweiShopV2Page extends OpenApiMobilePage
}
}
$vkeynum = count($arr);
//未付款卡密变为未使用
pdo_query("update " . tablename('ewei_shop_virtual_data') . ' set openid="",usetime=0,orderid=0,ordersn="",price=0,merchid=' . $item['merchid'] . ' where typeid=' . intval($typeid) . ' and orderid = ' . $item["id"]);
//模板减少使用数据
//核销减少使用数据
pdo_query("update " . tablename('ewei_shop_virtual_type') . " set usedata=usedata-" . $vkeynum . " where id=" . intval($typeid));
}
//加入好物圈收藏
// $goodscircle = p('goodscircle');
// if ($goodscircle) {
// $goodscircle->updateOrder($item['openid'], $item['id']);
// }
plog('order.op.close', "订单关闭 ID: {$item['id']} 订单号: {$item['ordersn']}");
return $this->success("订单关闭 ID: {$item['id']} 订单号: {$item['ordersn']}");
}
@ -1785,6 +1775,22 @@ class Detail_EweiShopV2Page extends OpenApiMobilePage
return $this->success("订单发货 ID: {$item['id']} 订单号: {$item['ordersn']}");
}
}
public function main()
{
global $_W, $_GPC;
$ordersn = $_GPC['order_sn'];
$orderid = intval($_GPC['order_id']);
return $this->result(m('wpfw')->get_order_info($orderid,$ordersn));
}
//推送
public function post()
{
global $_W, $_GPC;
$ordersn = $_GPC['order_sn'];
$orderid = intval($_GPC['order_id']);
return $this->result(m('wpfw')->order_post($orderid,$ordersn));
}
}
?>