| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 | <?phpnamespace Cas\Dao;use KIF\Dao\DBAgileDev;use KIF\Verify;/** *  * 微信群发任务 * @author lishumingoo@gmail.com */class WeixinMessageSend extends DBAgileDev {	protected $tableName = 'weixin_message_send';		/**	 * 数据库里的真实字段	 * @var array	 */	protected $other_field = array(		'description',		'msg_id',		'msgType',		'status',		'send_time',	);		/**	 * 群发消息类型:文字	 * @var string	 */	const TYPE_TEXT = 'text';		/**	 * 群发消息类型:图片	 * @var string	 */	const TYPE_IMG = 'image';		/**	 * 群发消息类型:图文	 * @var string	 */	const TYPE_TEXT_AND_IMG = 'news';		/**	 * 群发消息类型:语音	 * @var string	 */	const TYPE_VOICE = 'voice';			/**	 * 群发任务状态:等待发送	 * @var int	 */	const STATUS_WAIT_SEND = 100;		/**	 * 群发任务状态:发送成功	 * @var int	 */	const STATUS_SEND_SUCCESS = 200;		/**	 * 群发任务状态:发送是吧	 * @var unknown	 */	const STATUS_SEND_FAIL = 240;		/**	 * 群发任务状态:发送完成	 * @var int	 */	const STATUS_SEND_DONE = 300;		/**	 * 群发任务状态:取消发送	 * @var int	 */	const STATUS_CLOSED_SEND = 400;		static private $statusDesc =  array(		self::STATUS_WAIT_SEND => array(			'desc'	=> '等待发送',			'kw'	=> 'STATUS_WAIT_SEND',		),		self::STATUS_SEND_SUCCESS => array(			'desc'	=> '发送成功',			'kw'	=> 'STATUS_SEND_SUCCESS',		),		self::STATUS_SEND_FAIL => array(			'desc'	=> '发送失败',			'kw'	=> 'STATUS_SEND_FAIL',		),		self::STATUS_SEND_DONE => array(			'desc'	=> '发送完成',			'kw'	=> 'STATUS_SEND_DONE',		),		self::STATUS_CLOSED_SEND => array(			'desc'	=> '取消发送',			'kw'	=> 'STATUS_CLOSED_SEND',		),	);		static public function getsStatusDesc() {		return self::$statusDesc;	}		/**	 * 	 * 置为“等待发送”	 * @param int $id	 * @return boolean	 */	public function setWaitSend($id) {		$statusCondition = array(self::STATUS_CLOSED_SEND);		return $this->updateStatus($id, self::STATUS_WAIT_SEND, $statusCondition);	}		/**	 * 	 * 置为“取消发送”	 * @param int $id	 * @return boolean	 */	public function setClosedSend($id) {		$statusCondition = array(self::STATUS_WAIT_SEND);		return $this->updateStatus($id, self::STATUS_CLOSED_SEND, $statusCondition);	}		public function updateStatus($id, $status, array $statusCondition = null) {		if (!Verify::unsignedInt($id)) {			return false;		}			if (!in_array($status, array_keys(self::$statusDesc))) {			return false;		}			$tableInfo = array(			'status'	=> $status,			'update_time'	=> time(),		);			$condition = array(			'id'		=> $id,		);			if (!is_null($statusCondition)) {			$condition['status'] = $statusCondition;		}			return $this->update($tableInfo, $condition);	}}
 |