|
@@ -310,4 +310,105 @@ class Notify extends Api
|
|
|
echo $pay->success();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public function cancelorder() {
|
|
|
+ set_time_limit(0);
|
|
|
+
|
|
|
+ $where = array(
|
|
|
+ 'status' => 0,
|
|
|
+ 'createtime' => ['lt', time() - 1920],
|
|
|
+ );
|
|
|
+ $active_order = Db::name('active_order');
|
|
|
+ $list = $active_order->where($where)->limit(200)->select();
|
|
|
+
|
|
|
+ if (!$list) {
|
|
|
+ echo 'mei shu ju';
|
|
|
+ die;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $active_people = Db::name('active_people');
|
|
|
+ $active_people_modify = Db::name('active_people_modify');
|
|
|
+ $active = Db::name('active');
|
|
|
+
|
|
|
+ foreach ($list as &$v) {
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+
|
|
|
+ $rs = $active_order->where(['id' => $v['id'], 'status' => 0])->setField('status', 3);
|
|
|
+ if (!$rs) {
|
|
|
+ Db::rollback();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ $rt = $active_people->where(['order_id' => $v['id'], 'status' => 0])->setField(['status' => 3, 'modifystatus' => 0]);
|
|
|
+ if (!$rt) {
|
|
|
+ Db::rollback();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ $res = $active_people_modify->where(['order_id' => $v['id'], 'status' => 0])->setField('status', 2);
|
|
|
+ if ($res === false) {
|
|
|
+ Db::rollback();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ $active_info = $active->find($v['active_id']);
|
|
|
+ $currentperson = $active_info['currentperson'] - $v['number'];
|
|
|
+ $active_rs = $active->where(['id' => $v['active_id'], 'currentperson' => $active_info['currentperson']])->setField('currentperson', $currentperson);
|
|
|
+ if (!$active_rs) {
|
|
|
+ Db::rollback();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ }
|
|
|
+
|
|
|
+ echo 'wan bi';
|
|
|
+ die;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function sysmsg() {
|
|
|
+ set_time_limit(0);
|
|
|
+
|
|
|
+ $where = array(
|
|
|
+ 'starttime' => ['elt', time() + 86400],
|
|
|
+ 'msgstatus' => 0,
|
|
|
+ 'status' => ['neq', 3]
|
|
|
+ );
|
|
|
+
|
|
|
+ $active = Db::name('active');
|
|
|
+ $list = $active->where($where)->limit(200)->select();
|
|
|
+
|
|
|
+ if (!$list) {
|
|
|
+ echo 'mei shu ju';
|
|
|
+ die;
|
|
|
+ }
|
|
|
+
|
|
|
+ $active_order = Db::name('active_order');
|
|
|
+ $sys_msg = Db::name('sys_msg');
|
|
|
+
|
|
|
+ $data['type'] = 1;
|
|
|
+ $data['title'] = '活动通知';
|
|
|
+ $data['createtime'] = time();
|
|
|
+ foreach ($list as &$v) {
|
|
|
+
|
|
|
+ $active->where(['id' => $v['id']])->setField('msgstatus', 1);
|
|
|
+
|
|
|
+ $data['content'] = '您报名的' . $v['title'] . '活动即将开始,请规划好您的时间。活动集合时间:' . date('Y-m-d H:i', $v['collectiontime']) . ',活动集合地点:' . $v['collectionplace'];
|
|
|
+
|
|
|
+ $user_ids = $active_order->where(['active_id' => $v['id'], 'status' => 1])->column('user_id');
|
|
|
+ if ($user_ids) {
|
|
|
+ foreach ($user_ids as &$va) {
|
|
|
+ $data['user_id'] = $va;
|
|
|
+ $sys_msg->insertGetId($data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ echo 'wan bi';
|
|
|
+ die;
|
|
|
+ }
|
|
|
+
|
|
|
}
|