|
@@ -6,6 +6,85 @@ use Dever;
|
|
|
|
|
|
class Cron
|
|
|
{
|
|
|
+ public function refund_api()
|
|
|
+ {
|
|
|
+ $order_id = Dever::input('order_id');
|
|
|
+ if ($order_id) {
|
|
|
+ $where['order_id'] = $order_id;
|
|
|
+ }
|
|
|
+ $where['product_id'] = 28;
|
|
|
+ $where['status'] = 5;
|
|
|
+ $where['refund_status'] = 1;
|
|
|
+ $data = Dever::db('journal/order')->state($where);
|
|
|
+
|
|
|
+ $test = Dever::input('test');
|
|
|
+ if ($test == 1) {
|
|
|
+ print_r($data);die;
|
|
|
+ }
|
|
|
+ if ($data) {
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
+ $this->refundScore($v);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private function refundScore($data)
|
|
|
+ {
|
|
|
+ $score = 0;
|
|
|
+ if ($data['cash'] == 6) {
|
|
|
+ $score = 20;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($data['cash'] == 60) {
|
|
|
+ $score = 20*10;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($data['cash'] == 588) {
|
|
|
+ $score = 20*100;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($data['cash'] == 1728) {
|
|
|
+ $score = 20*300;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($data['cash'] == 3348) {
|
|
|
+ $score = 20*600;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($score > 0) {
|
|
|
+ $where['uid'] = $v['uid'];
|
|
|
+ $user = Dever::db('score/user')->one($where);
|
|
|
+ if ($user) {
|
|
|
+ $user_score = $user['score'] - $score;
|
|
|
+ if ($user_score < 0) {
|
|
|
+ $user_score = 0;
|
|
|
+ }
|
|
|
+ Dever::db('score/user')->update(array('where_id' => $user['id'], 'score' => $user_score));
|
|
|
+ }
|
|
|
+
|
|
|
+ $where['type'] = 4;
|
|
|
+ $where['data_id'] = 28;
|
|
|
+ $user = Dever::db('act/score')->one($where);
|
|
|
+ if ($user) {
|
|
|
+ $user_score = $user['score'] - $score;
|
|
|
+ if ($user_score < 0) {
|
|
|
+ $user_score = 0;
|
|
|
+ }
|
|
|
+ Dever::db('act/score')->update(array('where_id' => $user['id'], 'score' => $user_score));
|
|
|
+ }
|
|
|
+
|
|
|
+ Dever::db('journal/order')->update(array('where_id' => $data['id'], 'refund_status' => 2));
|
|
|
+ }
|
|
|
+
|
|
|
+ print_r($data);
|
|
|
+
|
|
|
+ print_r($score);
|
|
|
+
|
|
|
+ echo "\r\n";
|
|
|
+
|
|
|
+ return $score;
|
|
|
+ }
|
|
|
+
|
|
|
public function pays_api()
|
|
|
{
|
|
|
$where['product_id'] = 28;
|