Points.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class Points extends Model
  5. {
  6. protected $connection = 'mysql';
  7. protected $pk = 'id';
  8. protected $name = 'points';
  9. public function member()
  10. {
  11. return $this->hasOne(Member::class, 'id', 'uid');
  12. }
  13. public static function getdescription($item)
  14. {
  15. $data['addcustomer'] = "新增客户";
  16. $data['adddongtai'] = "写跟进";
  17. $data['upjieduan'] = "推进客户";
  18. $data['deal'] = "成交客户";
  19. return $data[$item];
  20. }
  21. public static function uppoints($params)
  22. {
  23. $item = $params['item'];
  24. $uid = $params['uid'];
  25. $cid = $params['cid'];
  26. $pointsConfig = Config::getconfig('points');
  27. $points = (int)$pointsConfig[$item];
  28. //更新积分
  29. if ($points) {
  30. self::create([
  31. 'weid' => weid(),
  32. 'uid' => $uid,
  33. 'cid' => $cid,
  34. 'points' => $points,
  35. 'description' => self::getdescription($item),
  36. 'prefix' => 1,
  37. 'creat_time' => time(),
  38. 'type' => 1
  39. ]);
  40. Users::where('id', $uid)->inc('points', (int) $points)->update();
  41. }
  42. }
  43. }