Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
my-yaf-project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenchuanwen
my-yaf-project
Commits
0d21c503
Commit
0d21c503
authored
Jan 03, 2019
by
wwccw0591
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
95114081
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
159 additions
and
176 deletions
+159
-176
OrderService.php
application/models/Business/Order/OrderService.php
+159
-176
No files found.
application/models/Business/Order/OrderService.php
View file @
0d21c503
...
...
@@ -89,35 +89,23 @@ class OrderServiceModel extends \Business\AbstractModel
}
/**
* 发送模板消息
*
* 发送付款消息
* @param $order
* @param $msg_tpl
* User: King <358887571@qq.com>
* Date: 201
8/12/28 0028
* Time: 上午 11:
3
1
* Date: 201
9/1/3 0003
* Time: 上午 11:
0
1
*/
public
function
sendTemplateMessage
()
{
public
function
sendPaymentMessage
(
$order
,
$msg_tpl
)
{
$model
=
\DAO\Order\OrderModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$model_member
=
\DAO\MemberModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$model_order_goods
=
\DAO\Order\OrderGoodsModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$settingDAO
=
\DAO\SettingModel
::
getInstance
();
$wechatCommon
=
WechatCommon
::
getInstance
();
$access_token
=
$wechatCommon
->
getAccessToken
();
$wxapp_templates
=
$settingDAO
->
getListCache
(
array
(
'wxapp_order_paysucc_tpl'
,
'wxapp_order_shipping_tpl'
,
'wxapp_order_receive_tpl'
));
//付款7天内付款消息通知
$where
=
array
(
'msg_status'
=>
array
(
'elt'
,
1
),
'payment_type'
=>
5
,
'order_state'
=>
array
(
'egt'
,
20
),
'prepay_id'
=>
array
(
'neq'
,
''
),
'payment_time'
=>
array
(
'gt'
,
TIMESTAMP
-
7
*
24
*
60
*
60
));
if
(
$list
=
$model
->
getList
(
$where
,
'order_id,order_sn, store_name, buyer_id, order_amount, payment_time, order_state, prepay_id'
,
0
,
10
,
array
(
'payment_time'
=>
'asc'
)))
{
echo
$access_token
.
' order num: '
.
count
(
$list
[
'list'
])
.
"
\n
"
;
foreach
(
$list
[
'list'
]
as
$order
)
{
// \Our\Log::getInstance()->write('order:'.json_encode($order), '/data/log/apptest');
if
(
$access_token
&&
(
$member
=
$model_member
->
getOneByMemberId
(
$order
[
'buyer_id'
],
array
(
'member_id'
,
'member_wxappopenid'
)
)))
{
$where
=
array
(
'order_id'
=>
$order
[
'order_id'
]);
$goods_datas
=
$model_order_goods
->
getOrderGoods
(
$where
,
'order_id, goods_name'
);
$msg_tpl
=
$wxapp_templates
[
'wxapp_order_paysucc_tpl'
];
$goods_str
=
''
;
if
(
count
(
$goods_datas
)
>
1
)
{
$goods_str
.=
$goods_datas
[
0
][
'goods_name'
]
.
'等'
.
count
(
$goods_datas
)
.
'件商品'
;
...
...
@@ -139,27 +127,21 @@ class OrderServiceModel extends \Business\AbstractModel
$json
=
$wechatCommon
->
sendTemplateMessage
(
$access_token
,
$req_data
);
if
(
$json
[
'errmsg'
]
==
'ok'
)
{
$model
->
updateByOrderId
(
array
(
'msg_status'
=>
2
),
$order
[
'order_id'
]);
echo
'order['
.
$order
[
'order_id'
]
.
'] send payment succ'
.
"
\n
"
;
//
echo 'order[' . $order['order_id'] .'] send payment succ'."\n";
}
}
}
}
echo
"do payment
\n
"
;
//付款7天内订单发货通知
$where
=
array
(
'msg_status'
=>
2
,
'payment_type'
=>
5
,
'shipping_type'
=>
array
(
'in'
,
array
(
1
,
2
)),
'order_state'
=>
array
(
'egt'
,
30
),
'prepay_id'
=>
array
(
'neq'
,
''
),
'payment_time'
=>
array
(
'gt'
,
TIMESTAMP
-
7
*
24
*
60
*
60
),
'send_time'
=>
array
(
'lt'
,
TIMESTAMP
-
10
));
if
(
$list
=
$model
->
getList
(
$where
,
'order_id,order_sn,store_id,store_name,buyer_id,order_amount,add_time, send_time, order_state, prepay_id'
,
0
,
10
,
array
(
'send_time'
=>
'asc'
)))
{
echo
$access_token
.
' order num: '
.
count
(
$list
[
'list'
])
.
"
\n
"
;
public
function
sendShippingMessage
(
$order
,
$msg_tpl
)
{
$model
=
\DAO\Order\OrderModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$model_member
=
\DAO\MemberModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$model_order_goods
=
\DAO\Order\OrderGoodsModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$wechatCommon
=
WechatCommon
::
getInstance
();
$access_token
=
$wechatCommon
->
getAccessToken
();
$common_model
=
\DAO\Order\OrderCommonModel
::
getInstance
();
foreach
(
$list
[
'list'
]
as
$order
)
{
// \Our\Log::getInstance()->write('order:'.json_encode($order), '/data/log/apptest');
if
(
$access_token
&&
(
$member
=
$model_member
->
getOneByMemberId
(
$order
[
'buyer_id'
],
array
(
'member_id'
,
'member_wxappopenid'
)
)))
{
$msg_tpl
=
$wxapp_templates
[
'wxapp_order_shipping_tpl'
];
$sub_data
=
$common_model
->
findByOrderId
(
$order
[
'order_id'
],
'reciver_name, reciver_info'
);
$address
=
''
;
if
(
$sub_data
[
'reciver_info'
])
{
...
...
@@ -191,27 +173,22 @@ class OrderServiceModel extends \Business\AbstractModel
$json
=
$wechatCommon
->
sendTemplateMessage
(
$access_token
,
$req_data
);
if
(
$json
[
'errmsg'
]
==
'ok'
)
{
$model
->
updateByOrderId
(
array
(
'msg_status'
=>
3
),
$order
[
'order_id'
]);
echo
'order['
.
$order
[
'order_id'
]
.
'] send shipping succ'
.
"
\n
"
;
//
echo 'order[' . $order['order_id'] .'] send shipping succ'."\n";
}
}
}
}
echo
"do shipping
\n
"
;
//付款7天内订单确认收货通知
$where
=
array
(
'msg_status'
=>
3
,
'payment_type'
=>
5
,
'order_state'
=>
array
(
'egt'
,
40
),
'prepay_id'
=>
array
(
'neq'
,
''
),
'payment_time'
=>
array
(
'gt'
,
TIMESTAMP
-
7
*
24
*
60
*
60
),
'finnshed_time'
=>
array
(
'lt'
,
TIMESTAMP
-
15
));
if
(
$list
=
$model
->
getList
(
$where
,
'order_id,order_sn,store_id,store_name,buyer_id, shipping_type,order_amount,add_time, send_time, finnshed_time, order_state, prepay_id'
,
0
,
10
,
array
(
'finnshed_time'
=>
'asc'
)))
{
echo
$access_token
.
' order num: '
.
count
(
$list
[
'list'
])
.
"
\n
"
;
public
function
sendReceiveMessage
(
$order
,
$msg_tpl
)
{
$model
=
\DAO\Order\OrderModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$model_member
=
\DAO\MemberModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$model_order_goods
=
\DAO\Order\OrderGoodsModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$wechatCommon
=
WechatCommon
::
getInstance
();
$access_token
=
$wechatCommon
->
getAccessToken
();
$store_model
=
\DAO\StoreModel
::
getInstance
();
foreach
(
$list
[
'list'
]
as
$order
)
{
// \Our\Log::getInstance()->write('order:'.json_encode($order), '/data/log/apptest');
if
(
$access_token
&&
(
$member
=
$model_member
->
getOneByMemberId
(
$order
[
'buyer_id'
],
array
(
'member_id'
,
'member_wxappopenid'
)
)))
{
$msg_tpl
=
$wxapp_templates
[
'wxapp_order_receive_tpl'
];
$where
=
array
(
'order_id'
=>
$order
[
'order_id'
]);
$goods_datas
=
$model_order_goods
->
getOrderGoods
(
$where
,
'order_id, goods_name'
);
$goods_str
=
''
;
...
...
@@ -252,11 +229,65 @@ class OrderServiceModel extends \Business\AbstractModel
$json
=
$wechatCommon
->
sendTemplateMessage
(
$access_token
,
$req_data
);
if
(
$json
[
'errmsg'
]
==
'ok'
)
{
$model
->
updateByOrderId
(
array
(
'msg_status'
=>
4
),
$order
[
'order_id'
]);
echo
'order['
.
$order
[
'order_id'
]
.
'] send reciver succ'
.
"
\n
"
;
// echo 'order[' . $order['order_id'] .'] send reciver succ'."\n";
}
}
}
/**
* 发送模板消息
*
* User: King <358887571@qq.com>
* Date: 2018/12/28 0028
* Time: 上午 11:31
*/
public
function
sendTemplateMessage
()
{
$model
=
\DAO\Order\OrderModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$settingDAO
=
\DAO\SettingModel
::
getInstance
();
$wxapp_templates
=
$settingDAO
->
getListCache
(
array
(
'wxapp_order_paysucc_tpl'
,
'wxapp_order_shipping_tpl'
,
'wxapp_order_receive_tpl'
));
//付款7天内付款消息通知
$where
=
array
(
'msg_status'
=>
array
(
'elt'
,
1
),
'payment_type'
=>
5
,
'order_state'
=>
array
(
'egt'
,
20
),
'prepay_id'
=>
array
(
'neq'
,
''
),
'payment_time'
=>
array
(
'gt'
,
TIMESTAMP
-
7
*
24
*
60
*
60
));
if
(
$list
=
$model
->
getList
(
$where
,
'order_id,order_sn, store_name, buyer_id, order_amount, payment_time, order_state, prepay_id'
,
0
,
10
,
array
(
'payment_time'
=>
'asc'
)))
{
echo
'order count: '
.
count
(
$list
[
'list'
])
.
"
\n
"
;
$msg_tpl
=
$wxapp_templates
[
'wxapp_order_paysucc_tpl'
];
foreach
(
$list
[
'list'
]
as
$order
)
{
// \Our\Log::getInstance()->write('order:'.json_encode($order), '/data/log/apptest');
$this
->
sendPaymentMessage
(
$order
,
$msg_tpl
);
}
}
echo
"do payment
\n
"
;
//付款7天内订单发货通知
$where
=
array
(
'msg_status'
=>
2
,
'payment_type'
=>
5
,
'shipping_type'
=>
array
(
'in'
,
array
(
1
,
2
)),
'order_state'
=>
array
(
'egt'
,
30
),
'prepay_id'
=>
array
(
'neq'
,
''
),
'payment_time'
=>
array
(
'gt'
,
TIMESTAMP
-
7
*
24
*
60
*
60
),
'send_time'
=>
array
(
'lt'
,
TIMESTAMP
-
10
));
if
(
$list
=
$model
->
getList
(
$where
,
'order_id,order_sn,store_id,store_name,buyer_id,order_amount,add_time, send_time, order_state, prepay_id'
,
0
,
10
,
array
(
'send_time'
=>
'asc'
)))
{
echo
' order num: '
.
count
(
$list
[
'list'
])
.
"
\n
"
;
$msg_tpl
=
$wxapp_templates
[
'wxapp_order_shipping_tpl'
];
foreach
(
$list
[
'list'
]
as
$order
)
{
// \Our\Log::getInstance()->write('order:'.json_encode($order), '/data/log/apptest');
$this
->
sendShippingMessage
(
$order
,
$msg_tpl
);
}
}
echo
"do shipping
\n
"
;
//付款7天内订单确认收货通知
$where
=
array
(
'msg_status'
=>
3
,
'payment_type'
=>
5
,
'order_state'
=>
array
(
'egt'
,
40
),
'prepay_id'
=>
array
(
'neq'
,
''
),
'payment_time'
=>
array
(
'gt'
,
TIMESTAMP
-
7
*
24
*
60
*
60
),
'finnshed_time'
=>
array
(
'lt'
,
TIMESTAMP
-
15
));
if
(
$list
=
$model
->
getList
(
$where
,
'order_id,order_sn,store_id,store_name,buyer_id, shipping_type,order_amount,add_time, send_time, finnshed_time, order_state, prepay_id'
,
0
,
10
,
array
(
'finnshed_time'
=>
'asc'
)))
{
echo
' order num: '
.
count
(
$list
[
'list'
])
.
"
\n
"
;
$msg_tpl
=
$wxapp_templates
[
'wxapp_order_receive_tpl'
];
foreach
(
$list
[
'list'
]
as
$order
)
{
$this
->
sendReceiveMessage
(
$order
,
$msg_tpl
);
}
}
echo
"do reciver
\n
"
;
...
...
@@ -634,60 +665,12 @@ class OrderServiceModel extends \Business\AbstractModel
$push
->
addOneToClient
(
$pushData
);
$push
->
sendTcpMessage
();
$model_member
=
\DAO\MemberModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$wechatCommon
=
WechatCommon
::
getInstance
();
$access_token
=
$wechatCommon
->
getAccessToken
();
$order
[
'finnshed_time'
]
=
TIMESTAMP
;
$settingDAO
=
\DAO\SettingModel
::
getInstance
();
$wxapp_templates
=
$settingDAO
->
getListCache
(
array
(
'wxapp_order_receive_tpl'
));
if
(
$access_token
&&
(
$member
=
$model_member
->
getOneByMemberId
(
$order
[
'buyer_id'
],
array
(
'member_id'
,
'member_wxappopenid'
)
)))
{
$model_order_goods
=
\DAO\Order\OrderGoodsModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$msg_tpl
=
$wxapp_templates
[
'wxapp_order_receive_tpl'
];
$where
=
array
(
'order_id'
=>
$order
[
'order_id'
]);
$goods_datas
=
$model_order_goods
->
getOrderGoods
(
$where
,
'order_id, goods_name'
);
$goods_str
=
''
;
if
(
count
(
$goods_datas
)
>
1
)
{
$goods_str
.=
$goods_datas
[
0
][
'goods_name'
]
.
'等'
.
count
(
$goods_datas
)
.
'个商品'
;
}
else
{
$goods_str
.=
$goods_datas
[
0
][
'goods_name'
];
}
$store_data
=
$storeDao
->
getFieldsInfo
(
array
(
'store_id'
=>
$order
[
'store_id'
]),
'store_phone'
);
$shipping_type
=
''
;
switch
(
$order
[
'shipping_type'
])
{
case
1
:
$shipping_type
.=
'商家配送'
;
break
;
case
2
:
$shipping_type
.=
'快递配送'
;
break
;
default
:
$shipping_type
.=
'到店自提'
;
break
;
}
$req_data
=
array
(
'touser'
=>
$member
[
'member_wxappopenid'
],
'template_id'
=>
$msg_tpl
,
'form_id'
=>
$order
[
'prepay_id'
],
'page'
=>
'pages/orders/detail/index?id='
.
$order
[
'order_id'
],
'data'
=>
array
(
'keyword1'
=>
array
(
'value'
=>
$order
[
'order_sn'
]),
'keyword2'
=>
array
(
'value'
=>
date
(
'Y-m-d H:i'
,
$order
[
'send_time'
])),
'keyword3'
=>
array
(
'value'
=>
date
(
'Y-m-d H:i'
,
TIMESTAMP
)),
'keyword4'
=>
array
(
'value'
=>
$order
[
'store_name'
]),
'keyword5'
=>
array
(
'value'
=>
$store_data
[
'store_phone'
]),
'keyword6'
=>
array
(
'value'
=>
$goods_str
),
'keyword7'
=>
array
(
'value'
=>
number_format
(
$order
[
'order_amount'
]
/
100
,
2
)
.
'元'
),
'keyword8'
=>
array
(
'value'
=>
$shipping_type
),
'keyword9'
=>
array
(
'value'
=>
'您购买的商品已被签收,如不是您本人签收,请尽快联系商家'
),
));
// \Our\Log::getInstance()->write(json_encode($req_data), '/data/log/apptest');
$json
=
$wechatCommon
->
sendTemplateMessage
(
$access_token
,
$req_data
);
if
(
$json
[
'errmsg'
]
==
'ok'
)
{
$orderDao
->
updateByOrderId
(
array
(
'msg_status'
=>
4
),
$order
[
'order_id'
]);
}
}
$this
->
sendReceiveMessage
(
$order
,
$msg_tpl
);
//发送收货小程序模板消息
// \Our\RedisHelper::rpush('client_push',array('storeId'=>$order['storeId'],'type'=>$type,'op'=>NameConst::reduce,'num'=>ApiConst::one,'params'=>array('c'=>'shopkeeper','m'=>'orderDetail','orderId'=>$order['orderId'])));
$orderDao
->
deleteOrderCache
(
$memberId
,
$orderId
,
$order
[
'store_id'
],
true
,
true
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment