Commit 9fac3fc6 authored by liuyuzhen's avatar liuyuzhen

Merge branch 'master_dev' of git.shenbd.com:qm-develop/shenbd into lyz

parents 6878340f 2e0c00bf
......@@ -240,8 +240,13 @@ class ApiConst
const bySelf = 0;
const bySeller = 1;
const express = 2;
//待自提
const oneHandred=100;
const cancelOrderAuto=1;
const closeOrder=2;
const cancelOrderBySelf=4;
//待配送
const oneHandredOne=101;
......
......@@ -155,6 +155,8 @@ class NameConst {
const goodsCollection = 'goodsCollection';//商品收藏数量
const footprint = 'footprint';//足迹数量
const clientUpdateUrl='shenbd.zip';
const leftBracket = '[';
const rightBracket = ']';
const elasticName='elastic.master';
......
......@@ -2,6 +2,9 @@
namespace Business\Common;
use Our\Common;
use Our\NameConst;
class SettingServiceModel extends \Business\AbstractModel{
public function getCurrentVersion($param){
......@@ -22,7 +25,11 @@ class SettingServiceModel extends \Business\AbstractModel{
public function getAppVersion(){
$settingDAO = \DAO\SettingModel::getInstance();
$version = $settingDAO->getListCache(array('app_version'));
return array('version'=>$version['app_version']);
$updateUrl=\Bootstrap::getUrlIniConfig('ossHost');
$fileName='/'.NameConst::refund;
$updateUrl=$updateUrl.'/'.$fileName;
return array('version'=>$version['app_version'],'updateUrl'=>$updateUrl);
}
public function getServicePhone(){
......
......@@ -27,6 +27,30 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
* @throws \Exception
*/
public function setGoodsStorage($storeId, $goodsId, $num = 0, $type='add') {
$orderService=\Business\Order\OrderServiceModel::getInstance();
if($goodsId === 0){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::commonError);
}
if($type=='add'){
$type=ApiConst::plus;
}else{
$type=ApiConst::set;
}
$res=$orderService->updateGoodsStoregeByGoodsIds($storeId,$goodsId,$num,$type);
return $res;
}
/**
* 设置库存
* @param $storeId
* @param $goodsId
* @param int $num
* @param string $type
* @return array
* @throws \Exception
*/
public function setGoodsStorageBak($storeId, $goodsId, $num = 0, $type='add') {
if($goodsId === 0){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::commonError);
}
......
......@@ -332,8 +332,9 @@ class OrderServiceModel extends \Business\AbstractModel
$isAllowCancel = $orderDao->isAllowCancel($order);
$isAllowCance = true;
if ($isAllowCancel) {
$res = $orderDao->updateStatusByOrderId($orderId, ApiConst::orderStateCancel);
$res = $orderDao->updateStatusByOrderId($orderId, ApiConst::orderStateCancel,false,ApiConst::cancelOrderBySelf);
if ($res) {
$this->updateOrderGoodsStoregeByOrderIds(array($orderId));
$order['refundOrderNo']=$refundReturnDao->getRefundsn($order['storeId']);
if($order['paymentTime']>ApiConst::zero){
$resultRefund=$refundReturnDao->refundMoney($order);
......@@ -664,7 +665,7 @@ class OrderServiceModel extends \Business\AbstractModel
foreach ($orders as $order) {
//更新订单信息
$updateData = array('order_state' => ApiConst::orderStateCancel);
$updateData = array('order_state' => ApiConst::orderStateCancel,'is_effective'=>ApiConst::cancelOrderAuto);
$update = $orderDao->update(array('order_id' => $order['orderId']),$updateData);
$updateCommonData['order_message']=DescribeConst::cancelOrderMessage;
$res=$orderCommonDao->update(array('order_id'=>$order['orderId']),$updateCommonData);
......@@ -722,7 +723,7 @@ class OrderServiceModel extends \Business\AbstractModel
if (!empty($orders)) {
foreach ($orders as $order) {
//更新订单信息
$updateData = array('order_state' => ApiConst::orderStateClose,'refund_amount'=>$order['orderAmount']);
$updateData = array('order_state' => ApiConst::orderStateClose,'refund_amount'=>$order['orderAmount'],'gmt_update'=>TIMESTAMP,'is_effective'=>ApiConst::closeOrder);
$update = $orderDao->update(array('order_id' => $order['orderId']),$updateData);
if($update){
if ($order['paymentTime'] > ApiConst::zero && in_array($order['paymentType'], ArrayConst::orderPayTypeOnlines)) {
......@@ -775,23 +776,8 @@ class OrderServiceModel extends \Business\AbstractModel
}
file_put_contents($this->baseDir . \Our\PathConst::orderCloseWaitRecieveOrder, $endTime);
}
public function updateOrderGoodsStoregeByOrderIds($orderIds,$orderGoodsId=false){
$orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::masterDBConnectName);
public function updateDateGoodsStoregeByOrderGoods($orderGoods,$type=ApiConst::plus){
$orderConfirmUtilDao=OrderConfirmUtil::getInstance(DbNameConst::masterDBConnectName);
//更新商品库存
$orderGoodses = $orderGoodsDao->getOrderGoodsByOrderIds($orderIds, $this->getGoodsDetailField());
$orderGoods=array();
if(!empty($orderGoodsId)){
foreach($orderGoodses as $orderGood){
if($orderGood['recId']==$orderGoodsId){
array_push($orderGoods,$orderGood);
}
}
}
if(empty($orderGoods)){
$orderGoods=$orderGoodses;
}
$storeCartsList=array();
$storeCarts=array();
$storeCarts['storeCarts']=array();
......@@ -806,12 +792,49 @@ class OrderServiceModel extends \Business\AbstractModel
}
// $orderDao->updateNotRecieveOrders(ApiConst::orderStateWaitConfirm, ApiConst::orderStateClose, 'add_time', ApiConst::orderStateWaitConfirmBeyond, $this->orderMessageField);
try{
$orderConfirmUtilDao->updateGoodsStorage($storeCartsList,\Our\ApiConst::plus);
$orderConfirmUtilDao->updateGoodsStorage($storeCartsList,$type);
return true;
}catch(\Exception $ex){
$orderidsStr=implode(',',$orderIds);
$orderGoodsIds=array_column($orderGoods,'goodsId');
$orderidsStr=implode(',',$orderGoodsIds);
echo '商品库存更新失败:'.$ex->getMessage().$ex->getCode().":".$orderidsStr;
}
}
public function updateOrderGoodsStoregeByOrderIds($orderIds,$orderGoodsId=false){
$orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::masterDBConnectName);
//更新商品库存
$orderGoodses = $orderGoodsDao->getOrderGoodsByOrderIds($orderIds, $this->getGoodsDetailField());
$orderGoods=array();
if(!empty($orderGoodsId)){
foreach($orderGoodses as $orderGood){
if($orderGood['recId']==$orderGoodsId){
array_push($orderGoods,$orderGood);
}
}
}
if(empty($orderGoods)){
$orderGoods=$orderGoodses;
}
$this->updateDateGoodsStoregeByOrderGoods($orderGoods);
}
public function updateGoodsStoregeByGoodsIds($storeId,$goodsid,$num=ApiConst::zero,$type=ApiConst::plus){
$where['goods_id']=$goodsid;
$where['store_id']=$storeId;
$goodsDao = \DAO\GoodsModel::getInstance(DbNameConst::masterDBConnectName);
$goodses=$goodsDao->getList($where,$goodsDao->goodsDetailField);
if(!empty($goodses)){
foreach($goodses as &$goods){
$goods['goodsNum']=$num;
}
if($this->updateDateGoodsStoregeByOrderGoods($goodses,$type)){
return true;
}
}
return false;
}
//订单任务脚本自动确认收货
public function canformRecieveOrder()
......
......@@ -187,7 +187,7 @@ class RefundServiceModel extends \Business\AbstractModel
$orderDao->deleteOrderCache($refund['buyer_id'], $refund['order_id'], $refund['store_id']);
$storeDAO->deleteStoreRefundCache($refund['store_id'],$refund['order_id']);
$orderService=\Business\Order\OrderServiceModel::getInstance();
$orderService->updateOrderGoodsStoregeByOrderIds($refund['order_id']);
$orderService->updateOrderGoodsStoregeByOrderIds($refund['order_id'],$refund['goods_id']);
$refundReturnDao->db->doCommit();
$push=\Our\Push::getInstance();
$pushData=array('storeId'=>$storeId,
......
......@@ -407,7 +407,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
public function getOrders($memberId, $pageIndex, $pageSize, $orderState, $keyword)
{
$order = array('gmt_update' => 'desc');
$order = array('add_time' => 'desc');
$orderDao=\DAO\Order\OrderModel::getInstance();
$storeId = $this->_getStoreByMemberId($memberId);
if (empty($storeId)) {
......@@ -436,15 +436,21 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
// $where .= ' and han_order.shipping_type=' . ApiConst::bySelf;
$where=$orderDao->getByselfCondition($storeId);
} else {
// $order=array(
// 'diliveryman_id'=>'asc',
// 'gmt_update'=>'asc'
// );
$order=array(
'diliveryman_id'=>'asc',
'gmt_update'=>'asc'
'add_time'=>'desc'
);
// $where .= ' and han_order.shipping_type=' . ApiConst::bySeller;
$where=$orderDao->getWaitDeliveryCondition($storeId);
}
} else {
$order=array(
'add_time'=>'desc'
);
if (!empty($orderState)) {
$where .= ' and han_order.order_state=' . $orderState;
}
......
......@@ -20,7 +20,7 @@ class GoodsModel extends \DAO\AbstractModel {
private $cartGoodsField = 'goods_id,goods_storage,store_id,goods_commonid,goods_name,goods_image,goods_spec,snapshot_id';
public $goodsDetailField='goods_id as goodsId,goods_commonid as goodsCommonid,goods_name as goodsName,store_id as storeId';
public $goodsDetailField='goods_id as goodsId,goods_commonid as goodsCommonid,goods_commonid as goodsCommonId,goods_name as goodsName,store_id as storeId';
/**
* 主键
......@@ -502,8 +502,11 @@ class GoodsModel extends \DAO\AbstractModel {
}
unset($goods['goodsSpec']);
if(isset($goods['goodsGroup'])&&!empty($goods['goodsGroup'])){
$goods['goodsGroup']=$this->getGoodsGroup($goods['goodsGroup']);
$goods['goodsDiscountPrice']=array_sum($goods['goodsGroup'],'discountPrice');
$goods['goodsReduceAmount']=$goods['goodsPayPrice']-$goods['goodsDiscountPrice'];
}else{
$goods['goodsGroup']=array();
}
......
......@@ -263,7 +263,7 @@ class OrderModel extends \DAO\AbstractModel
return $this->update($where, $data);
}
public function updateStatusByOrderId($orderIds, $status, $isConfirm = false)
public function updateStatusByOrderId($orderIds, $status, $isConfirm = false,$is_effective=ApiConst::zero)
{
$this->setDb($this->dbName);
if (is_array($orderIds)) {
......@@ -276,6 +276,9 @@ class OrderModel extends \DAO\AbstractModel
$data['is_receive_payment']=ApiConst::receivePayment;
$data['payment_time']=TIMESTAMP;
}
$data['is_effective']=$is_effective;
$data['order_state'] = $status;
$data['finnshed_time']=TIMESTAMP;
if ($isConfirm) {
......
......@@ -260,6 +260,24 @@ class OrderGoodsModel extends \DAO\AbstractModel {
$res=$this->db->from($this->_tableName)->select($this->sumGoodsNum)->where($where)->group("buyer_id")->group("store_id")->fetchAll();
return $res;
}
public function getMemberStoreOrderGoodsCountBak($storeIds,$memberIds){
$this->setDb($this->dbName);
$orderDao=\DAO\Order\OrderModel::getInstance(DbNameConst::salveDBConnectName);
$whereOrder['store_id']=array('in',$storeIds);
$whereOrder['buyer_id']=array('in',$memberIds);
$whereOrder['order_state']=array('in',ArrayConst::orderCloseAndCancel);
$orderIds=$orderDao->getFieldByWhere($whereOrder,'order_id');
$where['store_id']=array('in',$storeIds);
$where['buyer_id']=array('in',$memberIds);
$where['is_refund']=array('neq',ApiConst::refundSuccess);
if($orderIds){
$where['order_id']=array('notin',$orderIds);
}
$where=$this->db->getSqlWhereByArray($where);
$res=$this->db->from($this->_tableName)->select($this->sumGoodsNum)->where($where)->group("buyer_id")->group("store_id")->fetchAll();
return $res;
}
public function convertRefundOrderGoods($orderGoods,$orderGoodsId){
$newOrderGoods=Array();
......
......@@ -17,6 +17,9 @@
<script src="//static.shenbd.com/lib/m/js/swiper-3.4.1.jquery.min.js"></script>
</head>
<body class="page-index">
<form>
<input name="data[image][]" />
</form>
<div class="wrap">
<h1 class="logo"><a href="#"><img src="//static.shenbd.com/lib/img/logo.png" alt=""></a></h1>
<section class="pn-download">
......
......@@ -84,8 +84,21 @@ class cliOrderClose extends basecli
$stores=$goodsCommonService->getGoodsCount($storesIds);
if(!empty($stores)){
foreach($stores as $store){
$addData=array('storeId'=>$store['storeId'],'type'=>\Our\ApiConst::messageGoodsAlert,'op'=>\Our\NameConst::set,'alertCount'=>$store['count'],'params'=>array());
$push->addOneToClient($addData);
$push=\Our\Push::getInstance();
$pushData=array('storeId'=>$store['storeId'],
'type'=>\Our\ApiConst::messageGoodsAlert,
'waitReceiveCount'=>ApiConst::zero,
'waitDeliveryCount'=>0,
'waitGetCount'=>0,
'orderCount'=>ApiConst::zero,
'waitRefundProccessCount'=>ApiConst::zero,
'waitRefundReceiveCount'=>ApiConst::zero,
'refundCount'=>ApiConst::zero,
'alertCount'=>$store['count'],
'params'=>array('c'=>'shopkeeper',
'm'=>'orderDetail',
'orderId'=>$store['orderId']));
$push->addOneToClient($pushData);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment